OuroborosM commited on
Commit
f908aec
·
1 Parent(s): b1d8650

add llmmath

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -15,6 +15,7 @@ from langchain.tools import BaseTool
15
  from langchain.tools import DuckDuckGoSearchRun
16
  from langchain.utilities import WikipediaAPIWrapper
17
  from langchain.python import PythonREPL
 
18
 
19
  import pinecone
20
  from pinecone.core.client.configuration import Configuration as OpenApiConfiguration
@@ -57,7 +58,7 @@ python_tool = Tool(
57
  )
58
 
59
  # tools = [DB_Search(), wikipedia_tool, duckduckgo_tool, python_tool]
60
- tools = [DB_Search(), duckduckgo_tool, python_tool]
61
 
62
  os.environ["OPENAI_API_TYPE"] = "azure"
63
  os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
@@ -71,6 +72,17 @@ chat = AzureChatOpenAI(
71
  deployment_name="Chattester",
72
  temperature=0,
73
  )
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  embeddings = OpenAIEmbeddings(deployment="model_embedding", chunk_size=15)
76
 
@@ -86,7 +98,7 @@ index = pinecone.Index(index_name)
86
  # print(pinecone.whoami())
87
  # print(index.describe_index_stats())
88
 
89
- llm = chat
90
  agent = initialize_agent(tools, llm,
91
  agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
92
  verbose = True,
 
15
  from langchain.tools import DuckDuckGoSearchRun
16
  from langchain.utilities import WikipediaAPIWrapper
17
  from langchain.python import PythonREPL
18
+ from langchain.chains import LLMMathChain
19
 
20
  import pinecone
21
  from pinecone.core.client.configuration import Configuration as OpenApiConfiguration
 
58
  )
59
 
60
  # tools = [DB_Search(), wikipedia_tool, duckduckgo_tool, python_tool]
61
+
62
 
63
  os.environ["OPENAI_API_TYPE"] = "azure"
64
  os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
 
72
  deployment_name="Chattester",
73
  temperature=0,
74
  )
75
+ llm = chat
76
+
77
+ llm_math = LLMMathChain(llm = llm)
78
+
79
+ math_tool = Tool(
80
+ name ='Calculator',
81
+ func = llm_math.run,
82
+ description ='Useful for when you need to answer questions about math.'
83
+ )
84
+
85
+ tools = [DB_Search(), duckduckgo_tool, python_tool, math_tool]
86
 
87
  embeddings = OpenAIEmbeddings(deployment="model_embedding", chunk_size=15)
88
 
 
98
  # print(pinecone.whoami())
99
  # print(index.describe_index_stats())
100
 
101
+
102
  agent = initialize_agent(tools, llm,
103
  agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
104
  verbose = True,