questions about current events",    )]Notice the usage of the chat_history variable in the PromptTemplate, which matches up with the dynamic key name in the ConversationBufferMemory.prefix = """Have a conversation with a human, answering the following questions as best you can. You have access to the following tools:"""suffix = """Begin!"{chat_history}Question: {input}{agent_scratchpad}"""prompt = ZeroShotAgent.create_prompt(    tools,    prefix=prefix,    suffix=suffix,    input_variables=["input", "chat_history", "agent_scratchpad"],)Now we can create the RedisChatMessageHistory backed by the database.message_history = RedisChatMessageHistory(    url="redis://localhost:6379/0", ttl=600, session_id="my-session")memory = ConversationBufferMemory(    memory_key="chat_history", chat_memory=message_history)We can now construct the LLMChain, with the Memory object, and then create the agent.llm_chain = LLMChain(llm=OpenAI(temperature=0), prompt=prompt)agent = ZeroShotAgent(llm_chain=llm_chain, tools=tools, verbose=True)agent_chain = AgentExecutor.from_agent_and_tools(    agent=agent, tools=tools, verbose=True, memory=memory)agent_chain.run(input="How many people live in canada?")            > Entering new AgentExecutor chain...    Thought: I need to find out the population of Canada    Action: Search    Action Input: Population of Canada    Observation: The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data. ¬∑ Canada¬†... Additional information related to Canadian population trends can be found on Statistics Canada's Population and Demography Portal. Population of Canada (real-¬†... Index to the latest information from the Census of Population. This survey conducted by Statistics Canada provides a statistical portrait of Canada and its¬†... 14 records ... Estimated number of persons by quarter of a year and by year, Canada, provinces and territories. The 2021 Canadian census
This notebook goes over adding memory to an Agent where the memory uses an external message store. Before going through this notebook, please walkthrough the following notebooks, as this will build on top of both of them:
This notebook goes over adding memory to an Agent where the memory uses an external message store. Before going through this notebook, please walkthrough the following notebooks, as this will build on top of both of them: ->: questions about current events",    )]Notice the usage of the chat_history variable in the PromptTemplate, which matches up with the dynamic key name in the ConversationBufferMemory.prefix = """Have a conversation with a human, answering the following questions as best you can. You have access to the following tools:"""suffix = """Begin!"{chat_history}Question: {input}{agent_scratchpad}"""prompt = ZeroShotAgent.create_prompt(    tools,    prefix=prefix,    suffix=suffix,    input_variables=["input", "chat_history", "agent_scratchpad"],)Now we can create the RedisChatMessageHistory backed by the database.message_history = RedisChatMessageHistory(    url="redis://localhost:6379/0", ttl=600, session_id="my-session")memory = ConversationBufferMemory(    memory_key="chat_history", chat_memory=message_history)We can now construct the LLMChain, with the Memory object, and then create the agent.llm_chain = LLMChain(llm=OpenAI(temperature=0), prompt=prompt)agent = ZeroShotAgent(llm_chain=llm_chain, tools=tools, verbose=True)agent_chain = AgentExecutor.from_agent_and_tools(    agent=agent, tools=tools, verbose=True, memory=memory)agent_chain.run(input="How many people live in canada?")            > Entering new AgentExecutor chain...    Thought: I need to find out the population of Canada    Action: Search    Action Input: Population of Canada    Observation: The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data. ¬∑ Canada¬†... Additional information related to Canadian population trends can be found on Statistics Canada's Population and Demography Portal. Population of Canada (real-¬†... Index to the latest information from the Census of Population. This survey conducted by Statistics Canada provides a statistical portrait of Canada and its¬†... 14 records ... Estimated number of persons by quarter of a year and by year, Canada, provinces and territories. The 2021 Canadian census