from langchain.agents import AgentExecutor, create_tool_calling_agent from langchain_community.tools.tavily_search import TavilySearchResults from langchain_core.prompts import ChatPromptTemplate tools = [TavilySearchResults(max_results=1)] prompt = ChatPromptTemplate.from_messages( [ ( "system", "You are a helpful assistant.", ), ("placeholder", "{chat_history}"), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ] ) # Construct the Tools agent agent = create_tool_calling_agent(llm, tools, prompt) # Create an agent executor by passing in the agent and tools agent_executor = AgentExecutor(agent=agent, tools=tools) agent_executor.invoke( {"input": "Who directed the 2023 film Oppenheimer and what is their age in days?"} )