Skip to content

Commit

Permalink
tutortial18
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Dec 17, 2023
1 parent f2a525c commit b0e01ae
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Binary file modified TUTORIAL18/tutorial18.pptx
Binary file not shown.
17 changes: 17 additions & 0 deletions tutorial16/main.py
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)
2 changes: 2 additions & 0 deletions tutorial16/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2023-12-15 20:37:40.420 | INFO  | __main__:<module>:17 - The current Prime Minister of India is Narendra Modi.
2023-12-15 20:38:30.181 | INFO  | __main__:<module>:17 - The current Prime Minister of Australia is Anthony Albanese.
Binary file modified tutorial16/tutorial16.pptx
Binary file not shown.
7 changes: 7 additions & 0 deletions tutorial18/main.py
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")

0 comments on commit b0e01ae

Please sign in to comment.