Class StructuredChatOutputParserWithRetries

A class that provides a wrapper around the StructuredChatOutputParser and OutputFixingParser classes. It extends the AgentActionOutputParser class and allows for retrying the output parsing using the OutputFixingParser if it is provided.

Example

const outputParser = new StructuredChatOutputParserWithRetries.fromLLM(
new ChatOpenAI({ temperature: 0 }),
{
toolNames: ["calculator", "random-number-generator"],
},
);
const result = await outputParser.parse(
"What is a random number between 5 and 10 raised to the second power?"
);

Hierarchy

Constructors

Methods

  • Returns the format instructions for parsing the output of an agent action in the style of the StructuredChatAgent.

    Returns string

    A string representing the format instructions.

  • Parses the given text and returns an AgentAction or AgentFinish object. Throws an OutputParserException if the parsing fails.

    Parameters

    • text: string

      The text to parse.

    • Optional callbacks: Callbacks

    Returns Promise<AgentAction | AgentFinish>

    A Promise that resolves to an AgentAction or AgentFinish object.

  • Creates a new StructuredChatOutputParserWithRetries instance from a BaseLanguageModel and options. The options can include a base parser and tool names.

    Parameters

    • llm: BaseLanguageModel<any, BaseLanguageModelCallOptions>

      A BaseLanguageModel instance.

    • options: Omit<StructuredChatOutputParserArgs, "outputFixingParser">

      Options for creating a StructuredChatOutputParserWithRetries instance.

    Returns StructuredChatOutputParserWithRetries

    A new StructuredChatOutputParserWithRetries instance.

Generated using TypeDoc