Output Parsers

Output parsers are used to transform the output of a language model into a more suitable format, particularly when generating structured data.

Response Schema

ResponseSchema is used to define the structure of the response returned by an output parser. You can use ResponseSchema to create custom schemas for your output parser, which can help validate and parse the output more effectively.

Parameters:

  • Name: The name of the schema.

  • Description: A brief description of the schema, including its purpose and any relevant details. This field helps others understand the schema's intended use.

  • Type: The type of the schema. For example, "object", "array", "string", "number", etc. This field indicates the top-level type of the schema.

Structured Output Parsers

StructuredOutputParser in Langchain is an output parser used to transform the raw output from a language model (LLM) into a more structured format. The primary responsibility of a structured output parser is to provide methods for getting format instructions and parsing the output from an LLM into a structured format. When using a StructuredOutputParser, you need to specify the response_schemas parameter, which should contain one or more ResponseSchema instances. The response_schemas parameter is used to define the expected structure of the output, and it helps the parser validate and transform the raw output from a language model into a more structured format.

Parameters

  • Response Schema

Example usage:

Last updated