refers to which tool to use, and action_input refers to the input to that tool. log can also be provided as more context (that can be used for logging, tracing, etc).AgentFinish is a response that contains the final message to be sent back to the user. This should be used to end an agent run.In this notebook we walk through how to create a custom LLM agent.Set up environment‚ÄãDo necessary imports, etc.from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParserfrom langchain.prompts import StringPromptTemplatefrom langchain.llms import OpenAIfrom langchain.utilities import SerpAPIWrapperfrom langchain.chains import LLMChainfrom typing import List, Unionfrom langchain.schema import AgentAction, AgentFinish, OutputParserExceptionimport reSet up tool‚ÄãSet up any tools the agent may want to use. This may be necessary to put in the prompt (so that the agent knows to use these tools).# Define which tools the agent can use to answer user queriessearch = SerpAPIWrapper()tools = [    Tool(        name="Search",        func=search.run,        description="useful for when you need to answer questions about current events"    )]Prompt template‚ÄãThis instructs the agent on what to do. Generally, the template should incorporate:tools: which tools the agent has access and how and when to call them.intermediate_steps: These are tuples of previous (AgentAction, Observation) pairs. These are generally not passed directly to the model, but the prompt template formats them in a specific way.input: generic user input# Set up the base templatetemplate = """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
This notebook goes through how to create your own custom LLM agent.
This notebook goes through how to create your own custom LLM agent. ->: refers to which tool to use, and action_input refers to the input to that tool. log can also be provided as more context (that can be used for logging, tracing, etc).AgentFinish is a response that contains the final message to be sent back to the user. This should be used to end an agent run.In this notebook we walk through how to create a custom LLM agent.Set up environment‚ÄãDo necessary imports, etc.from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParserfrom langchain.prompts import StringPromptTemplatefrom langchain.llms import OpenAIfrom langchain.utilities import SerpAPIWrapperfrom langchain.chains import LLMChainfrom typing import List, Unionfrom langchain.schema import AgentAction, AgentFinish, OutputParserExceptionimport reSet up tool‚ÄãSet up any tools the agent may want to use. This may be necessary to put in the prompt (so that the agent knows to use these tools).# Define which tools the agent can use to answer user queriessearch = SerpAPIWrapper()tools = [    Tool(        name="Search",        func=search.run,        description="useful for when you need to answer questions about current events"    )]Prompt template‚ÄãThis instructs the agent on what to do. Generally, the template should incorporate:tools: which tools the agent has access and how and when to call them.intermediate_steps: These are tuples of previous (AgentAction, Observation) pairs. These are generally not passed directly to the model, but the prompt template formats them in a specific way.input: generic user input# Set up the base templatetemplate = """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