Skip to main content
Version: Next

Function: fixAndValidateStructuredOutput()

fixAndValidateStructuredOutput<T>(output, responseSchema): output<T>

Defined in: utils/llm.ts:102

Fixes and validates structured output from LLMs against a provided schema.

Type Parameters

T

T extends $ZodType

Parameters

output

string

The raw output string from the LLM.

responseSchema

any

The schema (Zod or JSON Schema) to validate the output against.

Returns

output<T>

The validated and parsed output.