Lab9 IR Using Agents Tools
Lab9 IR Using Agents Tools
import pprint as p
pp = p.PrettyPrinter(indent = 4)
pp.pprint(get_all_tool_names())
prompt = "When was the 3rd President of United States born? What is that year raised to the power
3?"
llm = OpenAI(temperature = 0)
llm=llm)
agent = initialize_agent(tools,
llm,
agent = 'zero-shot-react-description',
verbose = True)
agent.run(prompt)
################################################################
# we may need to use the tools like Google Search, wikipedia, calculator - llm-math
llm = OpenAI(temperature = 0)
search = SerpAPIWrapper()
wikipedia = WikipediaAPIWrapper()
#create Tools
tools = [
Tool(
name = "Search",
func = search.run,
description= "Useful when you have to answer questions about current events"
),
Tool(
name = "Wikipedia",
func = wikipedia.run,
),
Tool(
name = "Calculator",
func = llm_mathchain.run,
),
# For planner and executor model we need a model with the context information.
# Hence for Plan and Execute models( use ChatOpenAI to leverage previous information
model = ChatOpenAI(temperature = 0)
planner = load_chat_planner(model)
agent.run(prompt)