values from the text, which tightly couples the tool representation to the agent prompt. This is still useful if the underlying language model can't reliably generate structured schema. Let's take the multiplication function as an example. In order to use this, we will tell the agent to generate the "Action Input" as a comma-separated list of length two. We will then write a thin wrapper that takes a string, splits it into two around a comma, and passes both parsed sides as integers to the multiplication function.from langchain.llms import OpenAIfrom langchain.agents import initialize_agent, Toolfrom langchain.agents import AgentTypeHere is the multiplication function, as well as a wrapper to parse a string as input.def multiplier(a, b):    return a * bdef parsing_multiplier(string):    a, b = string.split(",")    return multiplier(int(a), int(b))llm = OpenAI(temperature=0)tools = [    Tool(        name="Multiplier",        func=parsing_multiplier,        description="useful for when you need to multiply two numbers together. The input to this tool should be a comma separated list of numbers of length two, representing the two numbers you want to multiply together. For example, `1,2` would be the input if you wanted to multiply 1 by 2.",    )]mrkl = initialize_agent(    tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)mrkl.run("What is 3 times 4")            > Entering new AgentExecutor chain...     I need to multiply two numbers    Action: Multiplier    Action Input: 3,4    Observation: 12    Thought: I now know the final answer    Final Answer: 3 times 4 is 12        > Finished chain.    '3 times 4 is 12'PreviousHuman-in-the-loop Tool ValidationNextTool Input SchemaMulti-Input Tools with a string formatCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
This notebook shows how to use a tool that requires multiple inputs with an agent. The recommended way to do so is with the StructuredTool class.
This notebook shows how to use a tool that requires multiple inputs with an agent. The recommended way to do so is with the StructuredTool class. ->: values from the text, which tightly couples the tool representation to the agent prompt. This is still useful if the underlying language model can't reliably generate structured schema. Let's take the multiplication function as an example. In order to use this, we will tell the agent to generate the "Action Input" as a comma-separated list of length two. We will then write a thin wrapper that takes a string, splits it into two around a comma, and passes both parsed sides as integers to the multiplication function.from langchain.llms import OpenAIfrom langchain.agents import initialize_agent, Toolfrom langchain.agents import AgentTypeHere is the multiplication function, as well as a wrapper to parse a string as input.def multiplier(a, b):    return a * bdef parsing_multiplier(string):    a, b = string.split(",")    return multiplier(int(a), int(b))llm = OpenAI(temperature=0)tools = [    Tool(        name="Multiplier",        func=parsing_multiplier,        description="useful for when you need to multiply two numbers together. The input to this tool should be a comma separated list of numbers of length two, representing the two numbers you want to multiply together. For example, `1,2` would be the input if you wanted to multiply 1 by 2.",    )]mrkl = initialize_agent(    tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)mrkl.run("What is 3 times 4")            > Entering new AgentExecutor chain...     I need to multiply two numbers    Action: Multiplier    Action Input: 3,4    Observation: 12    Thought: I now know the final answer    Final Answer: 3 times 4 is 12        > Finished chain.    '3 times 4 is 12'PreviousHuman-in-the-loop Tool ValidationNextTool Input SchemaMulti-Input Tools with a string formatCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.