Spaces:
Running
Running
Update agent_langchain.py
Browse files- agent_langchain.py +8 -12
agent_langchain.py
CHANGED
@@ -2,7 +2,6 @@ import os
|
|
2 |
|
3 |
from datetime import date
|
4 |
from langchain.agents import AgentType, initialize_agent, load_tools, tool
|
5 |
-
from langchain.callbacks import get_openai_callback
|
6 |
from langchain.chat_models import ChatOpenAI
|
7 |
|
8 |
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"
|
@@ -25,16 +24,13 @@ def agent_langchain(config, prompt):
|
|
25 |
|
26 |
tools = load_tools(["openweathermap-api"])
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
)
|
37 |
|
38 |
-
print(str(callback))
|
39 |
-
|
40 |
return agent(prompt)
|
|
|
2 |
|
3 |
from datetime import date
|
4 |
from langchain.agents import AgentType, initialize_agent, load_tools, tool
|
|
|
5 |
from langchain.chat_models import ChatOpenAI
|
6 |
|
7 |
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"
|
|
|
24 |
|
25 |
tools = load_tools(["openweathermap-api"])
|
26 |
|
27 |
+
agent = initialize_agent(
|
28 |
+
tools + # built-in tools
|
29 |
+
[today_tool], # custom tools
|
30 |
+
llm,
|
31 |
+
agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
|
32 |
+
handle_parsing_errors = True,
|
33 |
+
verbose = True
|
34 |
+
)
|
|
|
35 |
|
|
|
|
|
36 |
return agent(prompt)
|