langchain.js
    Preparing search index...

    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.

    const outputParser = new StructuredChatOutputParserWithRetries.fromLLM(
    new ChatOpenAI({ model: "gpt-4o-mini", 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 (View Summary)

    Index

    Constructors

    Properties

    lc_namespace: string[] = ...

    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.

      • Optionalcallbacks: any

      Returns Promise<any>

      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: BaseLanguageModelInterface

        A BaseLanguageModel instance.

      • options: Omit<StructuredChatOutputParserArgs, "outputFixingParser">

        Options for creating a StructuredChatOutputParserWithRetries instance.

      Returns StructuredChatOutputParserWithRetries

      A new StructuredChatOutputParserWithRetries instance.