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"sQuestion: {input}{agent_scratchpad}"""# Set up a prompt templateclass CustomPromptTemplate(StringPromptTemplate):    # The template to use    template: str    # The list of tools available    tools: List[Tool]    def format(self, **kwargs) -> str:        # Get the intermediate steps (AgentAction, Observation tuples)        # Format them in a particular way        intermediate_steps = kwargs.pop("intermediate_steps")        thoughts = ""        for action, observation in intermediate_steps:            thoughts += action.log            thoughts += f"\nObservation: {observation}\nThought: "        # Set the agent_scratchpad variable to that value        kwargs["agent_scratchpad"] = thoughts        # Create a tools variable from the list of tools provided        kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools])        # Create a list of tool names for the tools provided        kwargs["tool_names"] = ", ".join([tool.name for tool in self.tools])        return self.template.format(**kwargs)prompt = CustomPromptTemplate(    template=template,    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"])Output parser‚ÄãThe output parser is responsible for parsing the LLM output into AgentAction and AgentFinish. This usually depends heavily on the prompt used.This is where you can change the parsing to do retries, handle whitespace, etc.class CustomOutputParser(AgentOutputParser):    def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:        # Check if
This notebook goes through how to create your own custom LLM agent.
This notebook goes through how to create your own custom LLM agent. ->: 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"sQuestion: {input}{agent_scratchpad}"""# Set up a prompt templateclass CustomPromptTemplate(StringPromptTemplate):    # The template to use    template: str    # The list of tools available    tools: List[Tool]    def format(self, **kwargs) -> str:        # Get the intermediate steps (AgentAction, Observation tuples)        # Format them in a particular way        intermediate_steps = kwargs.pop("intermediate_steps")        thoughts = ""        for action, observation in intermediate_steps:            thoughts += action.log            thoughts += f"\nObservation: {observation}\nThought: "        # Set the agent_scratchpad variable to that value        kwargs["agent_scratchpad"] = thoughts        # Create a tools variable from the list of tools provided        kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools])        # Create a list of tool names for the tools provided        kwargs["tool_names"] = ", ".join([tool.name for tool in self.tools])        return self.template.format(**kwargs)prompt = CustomPromptTemplate(    template=template,    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"])Output parser‚ÄãThe output parser is responsible for parsing the LLM output into AgentAction and AgentFinish. This usually depends heavily on the prompt used.This is where you can change the parsing to do retries, handle whitespace, etc.class CustomOutputParser(AgentOutputParser):    def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:        # Check if