bstraehle commited on
Commit
e472bde
·
1 Parent(s): 494b05b

Update agent_langchain.py

Browse files
Files changed (1) hide show
  1. 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
- with get_openai_callback() as callback:
29
- agent = initialize_agent(
30
- tools + # built-in tools
31
- [today_tool], # custom tools
32
- llm,
33
- agent = AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
34
- handle_parsing_errors = True,
35
- verbose = True
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)