"        # Set the agent_scratchpad variable to that value        kwargs["agent_scratchpad"] = thoughts        ############## NEW ######################        tools = self.tools_getter(kwargs["input"])        # Create a tools variable from the list of tools provided        kwargs["tools"] = "\n".join(            [f"{tool.name}: {tool.description}" for tool in tools]        )        # Create a list of tool names for the tools provided        kwargs["tool_names"] = ", ".join([tool.name for tool in tools])        return self.template.format(**kwargs)prompt = CustomPromptTemplate(    template=template,    tools_getter=get_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 unchanged from the previous notebook, since we are not changing anything about the output format.class CustomOutputParser(AgentOutputParser):    def parse(self, llm_output: str) -> Union[AgentAction, 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 ValueError(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,
This notebook builds off of this notebook and assumes familiarity with how agents work.
This notebook builds off of this notebook and assumes familiarity with how agents work. ->: "        # Set the agent_scratchpad variable to that value        kwargs["agent_scratchpad"] = thoughts        ############## NEW ######################        tools = self.tools_getter(kwargs["input"])        # Create a tools variable from the list of tools provided        kwargs["tools"] = "\n".join(            [f"{tool.name}: {tool.description}" for tool in tools]        )        # Create a list of tool names for the tools provided        kwargs["tool_names"] = ", ".join([tool.name for tool in tools])        return self.template.format(**kwargs)prompt = CustomPromptTemplate(    template=template,    tools_getter=get_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 unchanged from the previous notebook, since we are not changing anything about the output format.class CustomOutputParser(AgentOutputParser):    def parse(self, llm_output: str) -> Union[AgentAction, 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 ValueError(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,