这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ANTHROPIC_API_KEY=
COHERE_API_KEY=
BING_SUBSCRIPTION_KEY=
BING_SEARCH_URL=
WOLFRAM_ALPHA_APPID=

#For Azure OpenAI
AZURE_API_KEY=
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,3 @@ We appreciate your contributions and aim to make it easy for anyone to create an
## Support

We appreciate all the support you can give us, either with contributions, feedback, bug reports or feature requests. Drop a star and share Superagent to the world!

[![Star History Chart](https://api.star-history.com/svg?repos=homanp/superagent&type=Date)](https://superagent.sh)
7 changes: 5 additions & 2 deletions app/lib/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
agent_template,
default_chat_prompt,
)
from app.lib.tools import get_search_tool
from app.lib.tools import get_search_tool, get_wolfram_alpha_tool


class AgentBase:
Expand Down Expand Up @@ -73,7 +73,10 @@ def _get_tool(self) -> Any:
if self.tool.type == "SEARCH":
tools = get_search_tool()

return tools
if self.tool.type == "WOLFRAM_ALPHA":
tools = get_wolfram_alpha_tool()

return tools

except Exception:
return None
Expand Down
14 changes: 14 additions & 0 deletions app/lib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from decouple import config
from langchain.agents import Tool
from langchain.utilities import BingSearchAPIWrapper
from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapper


def get_search_tool() -> List:
Expand All @@ -19,3 +20,16 @@ def get_search_tool() -> List:
]

return tools


def get_wolfram_alpha_tool() -> List:
wolfram = WolframAlphaAPIWrapper()
tools = [
Tool(
name="Wolfram Alpha",
func=wolfram.run,
description="useful for when you need to do computation",
)
]

return tools
63 changes: 62 additions & 1 deletion poetry.lock

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "ToolType" ADD VALUE 'WOLFRAM_ALPHA';
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum DocumentType {
enum ToolType {
BROWSER
SEARCH
WOLFRAM_ALPHA
}

model User {
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pinecone-client = "^2.2.1"
tiktoken = "^0.4.0"
pypdf = "^3.8.1"
cohere = "^4.5.1"
wolframalpha = "^5.0.0"


[build-system]
Expand Down