AgentFinish]:        # Check if agent should finish        if "Final Answer:" in llm_output:            return AgentFinish(                # Return values is generally always a dictionary with a single `output` key                # It is not recommended to try anything else at the moment :)                return_values={"output": llm_output.split("Final Answer:")[-1].strip()},                log=llm_output,            )        # Parse out the action and action input        regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)"        match = re.search(regex, llm_output, re.DOTALL)        if not match:            raise OutputParserException(f"Could not parse LLM output: `{llm_output}`")        action = match.group(1).strip()        action_input = match.group(2)        # Return the action and action input        return AgentAction(tool=action, tool_input=action_input.strip(" ").strip('"'), log=llm_output)output_parser = CustomOutputParser()Set up LLM‚ÄãChoose the LLM you want to use!llm = OpenAI(temperature=0)Define the stop sequence‚ÄãThis is important because it tells the LLM when to stop generation.This depends heavily on the prompt and model you are using. Generally, you want this to be whatever token you use in the prompt to denote the start of an Observation (otherwise, the LLM may hallucinate an observation for you).Set up the Agent‚ÄãWe can now combine everything to set up our agent:# LLM chain consisting of the LLM and a promptllm_chain = LLMChain(llm=llm, prompt=prompt)tool_names = [tool.name for tool in tools]agent = LLMSingleActionAgent(    llm_chain=llm_chain,    output_parser=output_parser,    stop=["\nObservation:"],    allowed_tools=tool_names)Use the Agent‚ÄãNow we can use it!agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)agent_executor.run("How many people live in canada as of 2023?")    > Entering new AgentExecutor chain...    Thought: I need to find out the population of Canada in 2023
This notebook goes through how to create your own custom LLM agent.
This notebook goes through how to create your own custom LLM agent. ->: AgentFinish]:        # Check if agent should finish        if "Final Answer:" in llm_output:            return AgentFinish(                # Return values is generally always a dictionary with a single `output` key                # It is not recommended to try anything else at the moment :)                return_values={"output": llm_output.split("Final Answer:")[-1].strip()},                log=llm_output,            )        # Parse out the action and action input        regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)"        match = re.search(regex, llm_output, re.DOTALL)        if not match:            raise OutputParserException(f"Could not parse LLM output: `{llm_output}`")        action = match.group(1).strip()        action_input = match.group(2)        # Return the action and action input        return AgentAction(tool=action, tool_input=action_input.strip(" ").strip('"'), log=llm_output)output_parser = CustomOutputParser()Set up LLM‚ÄãChoose the LLM you want to use!llm = OpenAI(temperature=0)Define the stop sequence‚ÄãThis is important because it tells the LLM when to stop generation.This depends heavily on the prompt and model you are using. Generally, you want this to be whatever token you use in the prompt to denote the start of an Observation (otherwise, the LLM may hallucinate an observation for you).Set up the Agent‚ÄãWe can now combine everything to set up our agent:# LLM chain consisting of the LLM and a promptllm_chain = LLMChain(llm=llm, prompt=prompt)tool_names = [tool.name for tool in tools]agent = LLMSingleActionAgent(    llm_chain=llm_chain,    output_parser=output_parser,    stop=["\nObservation:"],    allowed_tools=tool_names)Use the Agent‚ÄãNow we can use it!agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)agent_executor.run("How many people live in canada as of 2023?")    > Entering new AgentExecutor chain...    Thought: I need to find out the population of Canada in 2023