diff --git a/src/helpers/zod.ts b/src/helpers/zod.ts index d12e7f3ca..4cb8c0a4b 100644 --- a/src/helpers/zod.ts +++ b/src/helpers/zod.ts @@ -12,6 +12,8 @@ import { zodToJsonSchema as _zodToJsonSchema } from '../_vendor/zod-to-json-sche import { AutoParseableResponseTool, makeParseableResponseTool } from '../lib/ResponsesParser'; import { type ResponseFormatTextJSONSchemaConfig } from '../resources/responses/responses'; +type Prettify = { [K in keyof T]: T[K] } & {}; + function zodToJsonSchema(schema: ZodType, options: { name: string }): Record { return _zodToJsonSchema(schema, { openaiStrictMode: true, @@ -63,7 +65,7 @@ export function zodResponseFormat( zodObject: ZodInput, name: string, props?: Omit, -): AutoParseableResponseFormat> { +): AutoParseableResponseFormat>> { return makeParseableResponseFormat( { type: 'json_schema', @@ -82,7 +84,7 @@ export function zodTextFormat( zodObject: ZodInput, name: string, props?: Omit, -): AutoParseableTextFormat> { +): AutoParseableTextFormat>> { return makeParseableTextFormat( { type: 'json_schema', @@ -103,12 +105,12 @@ export function zodTextFormat( export function zodFunction(options: { name: string; parameters: Parameters; - function?: ((args: zodInfer) => unknown | Promise) | undefined; + function?: ((args: Prettify>) => unknown | Promise) | undefined; description?: string | undefined; }): AutoParseableTool<{ - arguments: Parameters; + arguments: Prettify>; name: string; - function: (args: zodInfer) => unknown; + function: (args: Prettify>) => unknown; }> { // @ts-expect-error TODO return makeParseableTool( @@ -131,12 +133,12 @@ export function zodFunction(options: { export function zodResponsesFunction(options: { name: string; parameters: Parameters; - function?: ((args: zodInfer) => unknown | Promise) | undefined; + function?: ((args: Prettify>) => unknown | Promise) | undefined; description?: string | undefined; }): AutoParseableResponseTool<{ - arguments: Parameters; + arguments: Prettify>; name: string; - function: (args: zodInfer) => unknown; + function: (args: Prettify>) => unknown; }> { return makeParseableResponseTool( {