Parses ReAct-style LLM calls that have a single tool input.

Expects output to be in one of two formats.

If the output signals that an action should be taken, should be in the below format. This will result in an AgentAction being returned.

Thought: agent thought here
Action: search
Action Input: what is the temperature in SF?

If the output signals that a final answer should be given, should be in the below format. This will result in an AgentFinish being returned.

Thought: agent thought here
Final Answer: The temperature is 100 degrees

Example


const runnableAgent = RunnableSequence.from([
...rest of runnable
new ReActSingleInputOutputParser({ toolNames: ["SerpAPI", "Calculator"] }),
]);
const agent = AgentExecutor.fromAgentAndTools({
agent: runnableAgent,
tools: [new SerpAPI(), new Calculator()],
});
const result = await agent.invoke({
input: "whats the weather in pomfret?",
});

Hierarchy (view full)

Constructors

Methods

  • Returns the format instructions as a string. If the 'raw' option is true, returns the raw FORMAT_INSTRUCTIONS.

    Returns string

    Format instructions as a string.

  • Parses the given text into an AgentAction or AgentFinish object. If an output fixing parser is defined, uses it to parse the text.

    Parameters

    • text: string

      Text to parse.

    Returns Promise<AgentAction | AgentFinish>

    Promise that resolves to an AgentAction or AgentFinish object.

Generated using TypeDoc