AI: ChatGPT was developed by OpenAI.    Human: Thanks. Summarize the conversation, for my daughter 5 years old.    AI: ChatGPT is an artificial intelligence chatbot created by OpenAI that can send and receive images while chatting.For comparison, below is a bad example that uses the same memory for both the Agent and the tool.## This is a bad practice for using the memory.## Use the ReadOnlySharedMemory class, as shown above.template = """This is a conversation between a human and a bot:{chat_history}Write a summary of the conversation for {input}:"""prompt = PromptTemplate(input_variables=["input", "chat_history"], template=template)memory = ConversationBufferMemory(memory_key="chat_history")summary_chain = LLMChain(    llm=OpenAI(),    prompt=prompt,    verbose=True,    memory=memory,  # <--- this is the only change)search = GoogleSearchAPIWrapper()tools = [    Tool(        name="Search",        func=search.run,        description="useful for when you need to answer questions about current events",    ),    Tool(        name="Summary",        func=summary_chain.run,        description="useful for when you summarize a conversation. The input to this tool should be a string, representing who will read this summary.",    ),]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"],)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="What is ChatGPT?")            > Entering new AgentExecutor chain...    Thought: I should research ChatGPT to answer this question.
This notebook goes over adding memory to both an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them:
This notebook goes over adding memory to both an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them: ->: AI: ChatGPT was developed by OpenAI.    Human: Thanks. Summarize the conversation, for my daughter 5 years old.    AI: ChatGPT is an artificial intelligence chatbot created by OpenAI that can send and receive images while chatting.For comparison, below is a bad example that uses the same memory for both the Agent and the tool.## This is a bad practice for using the memory.## Use the ReadOnlySharedMemory class, as shown above.template = """This is a conversation between a human and a bot:{chat_history}Write a summary of the conversation for {input}:"""prompt = PromptTemplate(input_variables=["input", "chat_history"], template=template)memory = ConversationBufferMemory(memory_key="chat_history")summary_chain = LLMChain(    llm=OpenAI(),    prompt=prompt,    verbose=True,    memory=memory,  # <--- this is the only change)search = GoogleSearchAPIWrapper()tools = [    Tool(        name="Search",        func=search.run,        description="useful for when you need to answer questions about current events",    ),    Tool(        name="Summary",        func=summary_chain.run,        description="useful for when you summarize a conversation. The input to this tool should be a string, representing who will read this summary.",    ),]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"],)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="What is ChatGPT?")            > Entering new AgentExecutor chain...    Thought: I should research ChatGPT to answer this question.