-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from langchain.callbacks import FileCallbackHandler | ||
from langchain.chat_models import ChatOpenAI | ||
from langchain.agents import AgentType,initialize_agent,load_tools | ||
import os | ||
from loguru import logger | ||
|
||
os.environ["SERPAPI_API_KEY"]="c0e23b261ee29de6ab6155ca25f0e8845a9a8e1a60d2fd62bd1d95d9f8772bc6" | ||
llm=ChatOpenAI(temperature=0,model="gpt-4") | ||
tools=load_tools(["serpapi"],llm=llm) | ||
logfile="output.txt" | ||
|
||
|
||
handler=FileCallbackHandler(logfile) | ||
logger.add(logfile,colorize=True,enqueue=True) | ||
agent=initialize_agent(tools,llm,agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,handler=[handler],verbose=True) | ||
result=agent.run("who is the current prime minister of Australia") | ||
logger.info(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[32m2023-12-15 20:37:40.420[0m | [1mINFO [0m | [36m__main__[0m:[36m<module>[0m:[36m17[0m - [1mThe current Prime Minister of India is Narendra Modi.[0m | ||
[32m2023-12-15 20:38:30.181[0m | [1mINFO [0m | [36m__main__[0m:[36m<module>[0m:[36m17[0m - [1mThe current Prime Minister of Australia is Anthony Albanese.[0m |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from langchain.agents import AgentType,initialize_agent,load_tools | ||
from langchain.chat_models import ChatOpenAI | ||
|
||
llm=ChatOpenAI(temperature=0,model="gpt-4") | ||
tools=load_tools(["ddg-search"],llm=llm) | ||
agent=initialize_agent(tools,llm,agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,verbose=True) | ||
agent.run("what is latest news on 1st odi bertween India and south africa") |