/** * This module provides utilities for handling and validating JSON schema output. * * It includes the `OutputSchema` class, which captures, validates, and parses the * JSON schema of the output, and helper functions for type checking and string * representation of types. */ /** * An object that captures and validates/parses the JSON schema of the output. */ export declare class OutputSchema { /** The type of the output. */ private outputType; /** Whether the output type is wrapped in a dictionary. */ private isWrapped; /** The JSON schema of the output. */ private outputSchema; /** Whether the JSON schema is in strict mode. */ strictJsonSchema: boolean; /** * Initialize an OutputSchema for the given output type. * * @param outputType - The target TypeScript type of the LLM output. * @param strictJsonSchema - Whether to enforce strict JSON schema generation. */ constructor(outputType: unknown, strictJsonSchema?: boolean); /** * Whether the output type is plain text (versus a JSON object). */ isPlainText(): boolean; /** * The JSON schema of the output type. */ jsonSchema(): Record; /** * Validate a JSON string against the output type. * * Returns the validated object, or raises an error if the JSON is invalid. * * @param jsonStr - The JSON string to validate. * @param partial - Whether to allow partial JSON parsing. * @returns The validated object. */ validateJson(jsonStr: string): unknown; /** * Generate a JSON schema for a given type. * * This is a simplified implementation. In a full implementation, you might want to use * a library like `ts-json-schema-generator` or similar. * * @param type - The type to generate a schema for. * @returns The JSON schema. */ private generateJsonSchema; /** * Check if a type is a subclass of BaseModel or dict. * * @param type - The type to check. * @returns True if the type is a subclass of BaseModel or dict. */ private isSubclassOfBaseModelOrDict; } /** * Helper function to create an OutputSchema for a given type. * * @param outputType - The output type. * @param strictJsonSchema - Whether to enforce strict JSON schema. * @returns An OutputSchema instance. */ export declare function createOutputSchema(outputType: unknown, strictJsonSchema?: boolean): OutputSchema; /** * Check if a type can be represented as a JSON Schema object. * * @param type - The type to check. * @returns True if the type can be represented as a JSON Schema object. */ export declare function canRepresentAsJsonSchemaObject(type: unknown): boolean; //# sourceMappingURL=output.d.ts.map