Ketanji Brown Jackson to serve on the United States Supreme Court. The President described Judge Ketanji Brown Jackson as one of our nation's top legal minds who will continue Justice Breyer's legacy of excellence."Notice that the follow up question asks about information previously retrieved, so no need to do another retrievalresult = agent_executor({"input": "how long ago did he nominate her?"})            > Entering new AgentExecutor chain...    The President nominated Judge Ketanji Brown Jackson four days ago.        > Finished chain.result["output"]    'The President nominated Judge Ketanji Brown Jackson four days ago.'Creating from components‚ÄãWhat actually is going on underneath the hood? Let's take a look so we can understand how to modify going forward.There are a few components:The memoryThe prompt templateThe agentThe agent executor# This is needed for both the memory and the promptmemory_key = "history"The Memory‚ÄãIn this example, we want the agent to remember not only previous conversations, but also previous intermediate steps. For that, we can use AgentTokenBufferMemory. Note that if you want to change whether the agent remembers intermediate steps, or how the long the buffer is, or anything like that you should change this part.from langchain.agents.openai_functions_agent.agent_token_buffer_memory import AgentTokenBufferMemorymemory = AgentTokenBufferMemory(memory_key=memory_key, llm=llm)The Prompt Template‚ÄãFor the prompt template, we will use the OpenAIFunctionsAgent default way of creating one, but pass in a system prompt and a placeholder for memory.from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgentfrom langchain.schema.messages import SystemMessagefrom langchain.prompts import MessagesPlaceholdersystem_message = SystemMessage(        content=(            "Do your best to answer the questions. "            "Feel free to use any tools available to look up "            "relevant information, only if necessary"
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. ->: Ketanji Brown Jackson to serve on the United States Supreme Court. The President described Judge Ketanji Brown Jackson as one of our nation's top legal minds who will continue Justice Breyer's legacy of excellence."Notice that the follow up question asks about information previously retrieved, so no need to do another retrievalresult = agent_executor({"input": "how long ago did he nominate her?"})            > Entering new AgentExecutor chain...    The President nominated Judge Ketanji Brown Jackson four days ago.        > Finished chain.result["output"]    'The President nominated Judge Ketanji Brown Jackson four days ago.'Creating from components‚ÄãWhat actually is going on underneath the hood? Let's take a look so we can understand how to modify going forward.There are a few components:The memoryThe prompt templateThe agentThe agent executor# This is needed for both the memory and the promptmemory_key = "history"The Memory‚ÄãIn this example, we want the agent to remember not only previous conversations, but also previous intermediate steps. For that, we can use AgentTokenBufferMemory. Note that if you want to change whether the agent remembers intermediate steps, or how the long the buffer is, or anything like that you should change this part.from langchain.agents.openai_functions_agent.agent_token_buffer_memory import AgentTokenBufferMemorymemory = AgentTokenBufferMemory(memory_key=memory_key, llm=llm)The Prompt Template‚ÄãFor the prompt template, we will use the OpenAIFunctionsAgent default way of creating one, but pass in a system prompt and a placeholder for memory.from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgentfrom langchain.schema.messages import SystemMessagefrom langchain.prompts import MessagesPlaceholdersystem_message = SystemMessage(        content=(            "Do your best to answer the questions. "            "Feel free to use any tools available to look up "            "relevant information, only if necessary"