Class OutputFixingParser<T>

Class that extends the BaseOutputParser to handle situations where the initial parsing attempt fails. It contains a retryChain for retrying the parsing process in case of a failure.

Type Parameters

  • T

Hierarchy

  • BaseOutputParser<T>
    • OutputFixingParser

Constructors

  • Type Parameters

    • T

    Parameters

    • __namedParameters: {
          parser: BaseOutputParser<T>;
          retryChain: LLMChain<string, LLMType>;
      }
      • parser: BaseOutputParser<T>
      • retryChain: LLMChain<string, LLMType>

    Returns OutputFixingParser<T>

Properties

parser: BaseOutputParser<T>
retryChain: LLMChain<string, LLMType>

Methods

  • Method to get the format instructions for the parser.

    Returns string

    The format instructions for the parser.

  • Method to parse the completion using the parser. If the initial parsing fails, it uses the retryChain to attempt to fix the output and retry the parsing process.

    Parameters

    • completion: string

      The completion to be parsed.

    • Optional callbacks: Callbacks

      Optional callbacks to be used during parsing.

    Returns Promise<T>

    The parsed output.

  • Static method to create a new instance of OutputFixingParser using a given language model, parser, and optional fields.

    Type Parameters

    • T

    Parameters

    • llm: BaseLanguageModel<any, BaseLanguageModelCallOptions>

      The language model to be used.

    • parser: BaseOutputParser<T>

      The parser to be used.

    • Optional fields: {
          prompt?: BasePromptTemplate<any, BasePromptValue, any>;
      }

      Optional fields which may contain a prompt.

      • Optional prompt?: BasePromptTemplate<any, BasePromptValue, any>

    Returns OutputFixingParser<T>

    A new instance of OutputFixingParser.

Generated using TypeDoc