nat.agent.react_agent.output_parser#

Attributes#

Exceptions#

ReActOutputParserException

Inappropriate argument value (of correct type).

Classes#

ReActOutputParser

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

Module Contents#

FINAL_ANSWER_ACTION = 'Final Answer:'#
MISSING_ACTION_AFTER_THOUGHT_ERROR_MESSAGE = "Invalid Format: Missing 'Action:' after 'Thought:'"#
MISSING_ACTION_INPUT_AFTER_ACTION_ERROR_MESSAGE = "Invalid Format: Missing 'Action Input:' after 'Action:'"#
FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE = 'Parsing LLM output produced both a final answer and a parse-able action:'#
exception ReActOutputParserException(
observation=None,
missing_action=False,
missing_action_input=False,
final_answer_and_action=False,
)#

Bases: ValueError, langchain_core.exceptions.LangChainException

Inappropriate argument value (of correct type).

Initialize self. See help(type(self)) for accurate signature.

observation = None#
missing_action = False#
missing_action_input = False#
final_answer_and_action = False#
class ReActOutputParser#

Bases: langchain_classic.agents.agent.AgentOutputParser

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?

Observation: Waiting for the tool response...

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
get_format_instructions() str#
parse(
text: str,
) langchain_core.agents.AgentAction | langchain_core.agents.AgentFinish#

Parse text into agent action/finish.

property _type: str#