Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rihardsgravis authored and nfcampos committed Jan 26, 2024
1 parent 7dd02a6 commit e5b147e
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 418 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ TAVILY_API_KEY=placeholder
AZURE_OPENAI_DEPLOYMENT_NAME=placeholder
AZURE_OPENAI_API_KEY=placeholder
AZURE_OPENAI_API_BASE=placeholder
AZURE_OPENAI_API_VERSION=placeholder
AZURE_OPENAI_API_VERSION=placeholder
ROBOCORP_ACTION_SERVER_URL=https://dummy-action-server.robocorp.link
ROBOCORP_ACTION_SERVER_KEY=dummy-api-key
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ See [this guide](https://python.langchain.com/docs/modules/agents/tools/custom_t

If you want to use some preconfigured tools, these include:

**_Robocorp Action Server_**

Run AI Python based actions with [Robocorp Action Server](https://github.com/robocorp/robocorp).
Does not require a service API key, but it requires the credentials for a running Action Server instance to be defined:

```shell
ROBOCORP_ACTION_SERVER_URL=https://dummy-action-server.robocorp.link
ROBOCORP_ACTION_SERVER_KEY=dummy-api-key
```

**DuckDuckGo Search**

Search the web with [DuckDuckGo](https://pypi.org/project/duckduckgo-search/). Does not require any API keys.
Expand Down
6 changes: 5 additions & 1 deletion backend/app/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ def __init__(
)
_tools.append(get_retrieval_tool(assistant_id, retrieval_description))
else:
_tools.append(TOOLS[_tool]())
_returned_tools = TOOLS[_tool]()
if isinstance(_returned_tools, list):
_tools.extend(_returned_tools)
else:
_tools.append(_returned_tools)
_agent = get_agent_executor(_tools, agent, system_message)
agent_executor = _agent.with_config({"recursion_limit": 50})
super().__init__(
Expand Down
12 changes: 12 additions & 0 deletions backend/app/tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from enum import Enum

from langchain.pydantic_v1 import BaseModel, Field
Expand All @@ -13,6 +14,7 @@
from langchain_community.utilities.arxiv import ArxivAPIWrapper
from langchain_community.utilities.tavily_search import TavilySearchAPIWrapper
from langchain_community.vectorstores.redis import RedisFilter
from langchain_robocorp import ActionServerToolkit

from app.upload import vstore

Expand Down Expand Up @@ -100,8 +102,17 @@ def _get_tavily_answer():
tavily_search = TavilySearchAPIWrapper()
return TavilyAnswer(api_wrapper=tavily_search)

def _get_action_server():
toolkit = ActionServerToolkit(
url=os.environ.get("ROBOCORP_ACTION_SERVER_URL"),
api_key=os.environ.get("ROBOCORP_ACTION_SERVER_KEY")
)
tools = toolkit.get_tools()
return tools


class AvailableTools(str, Enum):
ACTION_SERVER = "Action Server by Robocorp"
DDG_SEARCH = "DDG Search"
TAVILY = "Search (Tavily)"
TAVILY_ANSWER = "Search (short answer, Tavily)"
Expand All @@ -115,6 +126,7 @@ class AvailableTools(str, Enum):


TOOLS = {
AvailableTools.ACTION_SERVER: _get_action_server,
AvailableTools.DDG_SEARCH: _get_duck_duck_go,
AvailableTools.ARXIV: _get_arxiv,
AvailableTools.YOU_SEARCH: _get_you_search,
Expand Down
2 changes: 2 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ langchain>=0.1.0
langserve>=0.0.23
langgraph
python-multipart
langchain-robocorp>=0.0.1

2 changes: 2 additions & 0 deletions frontend/src/components/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export default function SingleOptionField(props: {

const TOOL_DESCRIPTIONS = {
Retrieval: "Look up information in uploaded files.",
"Action Server by Robocorp":
"Run AI actions with [Robocorp Action Server](https://github.com/robocorp/robocorp).",
"DDG Search":
"Search the web with [DuckDuckGo](https://pypi.org/project/duckduckgo-search/).",
"Search (Tavily)":
Expand Down
Loading

0 comments on commit e5b147e

Please sign in to comment.