need to find out the population of Canada in 2023    Action: Search    Action Input: Population of Canada in 2023    Observation:The current population of Canada is 38,658,314 as of Wednesday, April 12, 2023, based on Worldometer elaboration of the latest United Nations data. I now know the final answer    Final Answer: Arrr, there be 38,658,314 people livin' in Canada as of 2023!    > Finished chain.    "Arrr, there be 38,658,314 people livin' in Canada as of 2023!"Adding Memory‚ÄãIf you want to add memory to the agent, you'll need to:Add a place in the custom prompt for the chat_historyAdd a memory object to the agent executor.# Set up the base templatetemplate_with_history = """Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools:{tools}Use the following format:Question: the input question you must answerThought: you should always think about what to doAction: the action to take, should be one of [{tool_names}]Action Input: the input to the actionObservation: the result of the action... (this Thought/Action/Action Input/Observation can repeat N times)Thought: I now know the final answerFinal Answer: the final answer to the original input questionBegin! Remember to speak as a pirate when giving your final answer. Use lots of "Arg"sPrevious conversation history:{history}New question: {input}{agent_scratchpad}"""prompt_with_history = CustomPromptTemplate(    template=template_with_history,    tools=tools,    # This omits the `agent_scratchpad`, `tools`, and `tool_names` variables because those are generated dynamically    # This includes the `intermediate_steps` variable because that is needed    input_variables=["input", "intermediate_steps", "history"])llm_chain = LLMChain(llm=llm, prompt=prompt_with_history)tool_names = [tool.name for tool in tools]agent = LLMSingleActionAgent(    llm_chain=llm_chain,    output_parser=output_parser,    stop=["\nObservation:"],
This notebook goes through how to create your own custom LLM agent.
This notebook goes through how to create your own custom LLM agent. ->: need to find out the population of Canada in 2023    Action: Search    Action Input: Population of Canada in 2023    Observation:The current population of Canada is 38,658,314 as of Wednesday, April 12, 2023, based on Worldometer elaboration of the latest United Nations data. I now know the final answer    Final Answer: Arrr, there be 38,658,314 people livin' in Canada as of 2023!    > Finished chain.    "Arrr, there be 38,658,314 people livin' in Canada as of 2023!"Adding Memory‚ÄãIf you want to add memory to the agent, you'll need to:Add a place in the custom prompt for the chat_historyAdd a memory object to the agent executor.# Set up the base templatetemplate_with_history = """Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools:{tools}Use the following format:Question: the input question you must answerThought: you should always think about what to doAction: the action to take, should be one of [{tool_names}]Action Input: the input to the actionObservation: the result of the action... (this Thought/Action/Action Input/Observation can repeat N times)Thought: I now know the final answerFinal Answer: the final answer to the original input questionBegin! Remember to speak as a pirate when giving your final answer. Use lots of "Arg"sPrevious conversation history:{history}New question: {input}{agent_scratchpad}"""prompt_with_history = CustomPromptTemplate(    template=template_with_history,    tools=tools,    # This omits the `agent_scratchpad`, `tools`, and `tool_names` variables because those are generated dynamically    # This includes the `intermediate_steps` variable because that is needed    input_variables=["input", "intermediate_steps", "history"])llm_chain = LLMChain(llm=llm, prompt=prompt_with_history)tool_names = [tool.name for tool in tools]agent = LLMSingleActionAgent(    llm_chain=llm_chain,    output_parser=output_parser,    stop=["\nObservation:"],