Class RouterOutputParser<Y>

A type of output parser that extends the JsonMarkdownStructuredOutputParser. It is used to parse the output of a router in LangChain. The class takes a schema and an optional RouterOutputParserInput object as parameters.

Type Parameters

  • Y extends z.ZodTypeAny

Hierarchy

Constructors

Properties

defaultDestination: string = "DEFAULT"
schema: Y

Methods

  • Overrides the parse method from JsonMarkdownStructuredOutputParser. This method takes a string as input, attempts to parse it, and returns the parsed text. If the destination of the parsed text matches the defaultDestination, the destination is set to null. If the parsing fails, an OutputParserException is thrown.

    Parameters

    • text: string

      The text to be parsed.

    Returns Promise<TypeOf<Y>>

    The parsed text as a Promise.

  • Creates a new StructuredOutputParser from a set of names and descriptions.

    Type Parameters

    • S extends {
          [key: string]: string;
      }

    Parameters

    • schemas: S

      An object where each key is a name and each value is a description

    Returns JsonMarkdownStructuredOutputParser<ZodObject<{
        [k: string]: T;
    }, "strip", ZodTypeAny, {}, {}>>

    A new instance of StructuredOutputParser.

Generated using TypeDoc