langchain.agents.output_parsers.react_json_single_input.ReActJsonSingleInputOutputParser¶
class langchain.agents.output_parsers.react_json_single_input.ReActJsonSingleInputOutputParser[source]¶
Bases: AgentOutputParser
Parses ReAct-style LLM calls that have a single tool input in json format.
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:
`
{
“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
`
param pattern = re.compile('^.*?`{3}(?:json)?\\n(.*?)`{3}.*?$', re.DOTALL)¶
Regex pattern to parse the output.
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶
Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
async ainvoke(input: str | langchain_core.messages.base.BaseMessage, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → T¶
Default implementation of ainvoke, calls invoke from a thread.