basant307/AI_Governance_Project
048
1import { ResponseFormatJSONSchema } from "../resources/index.js";2import type { infer as zodInfer, ZodType } from 'zod';3import { AutoParseableResponseFormat, AutoParseableTextFormat, AutoParseableTool } from "../lib/parser.js";4import { AutoParseableResponseTool } from "../lib/ResponsesParser.js";5import { type ResponseFormatTextJSONSchemaConfig } from "../resources/responses/responses.js";6/**7 * Creates a chat completion `JSONSchema` response format object from8 * the given Zod schema.9 *10 * If this is passed to the `.parse()`, `.stream()` or `.runTools()`11 * chat completion methods then the response message will contain a12 * `.parsed` property that is the result of parsing the content with13 * the given Zod object.14 *15 * ```ts16 * const completion = await client.chat.completions.parse({17 * model: 'gpt-4o-2024-08-06',18 * messages: [19 * { role: 'system', content: 'You are a helpful math tutor.' },20 * { role: 'user', content: 'solve 8x + 31 = 2' },21 * ],22 * response_format: zodResponseFormat(23 * z.object({24 * steps: z.array(z.object({25 * explanation: z.string(),26 * answer: z.string(),27 * })),28 * final_answer: z.string(),29 * }),30 * 'math_answer',31 * ),32 * });33 * const message = completion.choices[0]?.message;34 * if (message?.parsed) {35 * console.log(message.parsed);36 * console.log(message.parsed.final_answer);37 * }38 * ```39 *40 * This can be passed directly to the `.create()` method but will not41 * result in any automatic parsing, you'll have to parse the response yourself.42 */43export declare function zodResponseFormat<ZodInput extends ZodType>(zodObject: ZodInput, name: string, props?: Omit<ResponseFormatJSONSchema.JSONSchema, 'schema' | 'strict' | 'name'>): AutoParseableResponseFormat<zodInfer<ZodInput>>;44export declare function zodTextFormat<ZodInput extends ZodType>(zodObject: ZodInput, name: string, props?: Omit<ResponseFormatTextJSONSchemaConfig, 'schema' | 'type' | 'strict' | 'name'>): AutoParseableTextFormat<zodInfer<ZodInput>>;45/**46 * Creates a chat completion `function` tool that can be invoked47 * automatically by the chat completion `.runTools()` method or automatically48 * parsed by `.parse()` / `.stream()`.49 */50export declare function zodFunction<Parameters extends ZodType>(options: {51 name: string;52 parameters: Parameters;53 function?: ((args: zodInfer<Parameters>) => unknown | Promise<unknown>) | undefined;54 description?: string | undefined;55}): AutoParseableTool<{56 arguments: Parameters;57 name: string;58 function: (args: zodInfer<Parameters>) => unknown;59}>;60export declare function zodResponsesFunction<Parameters extends ZodType>(options: {61 name: string;62 parameters: Parameters;63 function?: ((args: zodInfer<Parameters>) => unknown | Promise<unknown>) | undefined;64 description?: string | undefined;65}): AutoParseableResponseTool<{66 arguments: Parameters;67 name: string;68 function: (args: zodInfer<Parameters>) => unknown;69}>;70//# sourceMappingURL=zod.d.ts.map