Under the hood, this agent is using the OpenAIFunctionsAgent, so we need to use an ChatOpenAI model.from langchain.agents.agent_toolkits import create_conversational_retrieval_agentfrom langchain.chat_models import ChatOpenAIllm = ChatOpenAI(temperature = 0)agent_executor = create_conversational_retrieval_agent(llm, tools, verbose=True)We can now try it out!result = agent_executor({"input": "hi, im bob"})            > Entering new AgentExecutor chain...    Hello Bob! How can I assist you today?        > Finished chain.result["output"]    'Hello Bob! How can I assist you today?'Notice that it remembers your nameresult = agent_executor({"input": "whats my name?"})            > Entering new AgentExecutor chain...    Your name is Bob.        > Finished chain.result["output"]    'Your name is Bob.'Notice that it now does retrievalresult = agent_executor({"input": "what did the president say about kentaji brown jackson in the most recent state of the union?"})            > Entering new AgentExecutor chain...        Invoking: `search_state_of_union` with `{'query': 'Kentaji Brown Jackson'}`            [Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you‚Äôre at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I‚Äôd like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer‚Äîan Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \n\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \n\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation‚Äôs top legal minds, who will continue Justice Breyer‚Äôs legacy of excellence.', metadata={'source':
This is an agent specifically optimized for doing retrieval when necessary and also holding a conversation.
This is an agent specifically optimized for doing retrieval when necessary and also holding a conversation. ->: Under the hood, this agent is using the OpenAIFunctionsAgent, so we need to use an ChatOpenAI model.from langchain.agents.agent_toolkits import create_conversational_retrieval_agentfrom langchain.chat_models import ChatOpenAIllm = ChatOpenAI(temperature = 0)agent_executor = create_conversational_retrieval_agent(llm, tools, verbose=True)We can now try it out!result = agent_executor({"input": "hi, im bob"})            > Entering new AgentExecutor chain...    Hello Bob! How can I assist you today?        > Finished chain.result["output"]    'Hello Bob! How can I assist you today?'Notice that it remembers your nameresult = agent_executor({"input": "whats my name?"})            > Entering new AgentExecutor chain...    Your name is Bob.        > Finished chain.result["output"]    'Your name is Bob.'Notice that it now does retrievalresult = agent_executor({"input": "what did the president say about kentaji brown jackson in the most recent state of the union?"})            > Entering new AgentExecutor chain...        Invoking: `search_state_of_union` with `{'query': 'Kentaji Brown Jackson'}`            [Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you‚Äôre at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I‚Äôd like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer‚Äîan Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \n\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \n\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation‚Äôs top legal minds, who will continue Justice Breyer‚Äôs legacy of excellence.', metadata={'source':