Skip to content

Commit

Permalink
Merge pull request #134 from langchain-ai/pr/rihardsgravis/133
Browse files Browse the repository at this point in the history
Rebase: Feat: Robocorp Action Server
  • Loading branch information
nfcampos authored Jan 30, 2024
2 parents bc19f43 + 3f5899a commit d461530
Show file tree
Hide file tree
Showing 9 changed files with 334 additions and 283 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 @@ -231,6 +231,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 @@ -100,7 +100,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
13 changes: 13 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 @@ -106,7 +108,17 @@ def _get_tavily_answer():
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 @@ -120,6 +132,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
19 changes: 18 additions & 1 deletion backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ wikipedia = "^1.4.0"
langchain-google-vertexai = "^0.0.3"
setuptools = "^69.0.3"
pdfminer-six = "^20231228"
langchain-robocorp = "^0.0.3"

[tool.poetry.group.dev.dependencies]
uvicorn = "^0.23.2"
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 @@ -140,6 +140,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 d461530

Please sign in to comment.