Skip to main content

Class: StructuredOutputParser<T>

output_parsers.StructuredOutputParser

Class to parse the output of an LLM call.

Type parameters

NameType
Textends z.ZodTypeAny

Hierarchy

Constructors

constructor

new StructuredOutputParser<T>(schema)

Type parameters

NameType
Textends ZodType<any, any, any, T>

Parameters

NameType
schemaT

Overrides

BaseOutputParser.constructor

Defined in

langchain/src/output_parsers/structured.ts:53

Properties

schema

schema: T

Defined in

langchain/src/output_parsers/structured.ts:53

Methods

_type

_type(): string

Return the string type key uniquely identifying this class of parser

Returns

string

Inherited from

BaseOutputParser._type

Defined in

langchain/src/schema/index.ts:169


getFormatInstructions

getFormatInstructions(): string

Return a string describing the format of the output.

Example

{
"foo": "bar"
}

Returns

string

Format instructions.

Overrides

BaseOutputParser.getFormatInstructions

Defined in

langchain/src/output_parsers/structured.ts:76


parse

parse(text): Promise<TypeOf<T>>

Parse the output of an LLM call.

Parameters

NameTypeDescription
textstringLLM output to parse.

Returns

Promise<TypeOf<T>>

Parsed output.

Overrides

BaseOutputParser.parse

Defined in

langchain/src/output_parsers/structured.ts:85


parseWithPrompt

parseWithPrompt(text, _prompt): Promise<unknown>

Parameters

NameType
textstring
_promptBasePromptValue

Returns

Promise<unknown>

Inherited from

BaseOutputParser.parseWithPrompt

Defined in

langchain/src/schema/index.ts:147


fromNamesAndDescriptions

Static fromNamesAndDescriptions<S>(schemas): StructuredOutputParser<ZodObject<{ [k: string]: T; }, "strip", ZodTypeAny, {}, {}>>

Type parameters

NameType
Sextends Object

Parameters

NameType
schemasS

Returns

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

Defined in

langchain/src/output_parsers/structured.ts:61


fromZodSchema

Static fromZodSchema<T>(schema): StructuredOutputParser<T>

Type parameters

NameType
Textends ZodType<any, any, any, T>

Parameters

NameType
schemaT

Returns

StructuredOutputParser<T>

Defined in

langchain/src/output_parsers/structured.ts:57