1
- import { ResponseFormatJSONSchema } from 'openai /resources' ;
2
- import type z from 'zod' ;
1
+ import { ResponseFormatJSONSchema } from '.. /resources/index ' ;
2
+ import type { infer as zodInfer , ZodType } from 'zod' ;
3
3
import {
4
4
AutoParseableResponseFormat ,
5
5
AutoParseableTool ,
8
8
} from '../lib/parser' ;
9
9
import { zodToJsonSchema as _zodToJsonSchema } from '../_vendor/zod-to-json-schema' ;
10
10
11
- function zodToJsonSchema ( schema : z . ZodType , options : { name : string } ) : Record < string , unknown > {
11
+ function zodToJsonSchema ( schema : ZodType , options : { name : string } ) : Record < string , unknown > {
12
12
return _zodToJsonSchema ( schema , {
13
13
openaiStrictMode : true ,
14
14
name : options . name ,
@@ -55,11 +55,11 @@ function zodToJsonSchema(schema: z.ZodType, options: { name: string }): Record<s
55
55
* This can be passed directly to the `.create()` method but will not
56
56
* result in any automatic parsing, you'll have to parse the response yourself.
57
57
*/
58
- export function zodResponseFormat < ZodInput extends z . ZodType > (
58
+ export function zodResponseFormat < ZodInput extends ZodType > (
59
59
zodObject : ZodInput ,
60
60
name : string ,
61
61
props ?: Omit < ResponseFormatJSONSchema . JSONSchema , 'schema' | 'strict' | 'name' > ,
62
- ) : AutoParseableResponseFormat < z . infer < ZodInput > > {
62
+ ) : AutoParseableResponseFormat < zodInfer < ZodInput > > {
63
63
return makeParseableResponseFormat (
64
64
{
65
65
type : 'json_schema' ,
@@ -79,15 +79,15 @@ export function zodResponseFormat<ZodInput extends z.ZodType>(
79
79
* automatically by the chat completion `.runTools()` method or automatically
80
80
* parsed by `.parse()` / `.stream()`.
81
81
*/
82
- export function zodFunction < Parameters extends z . ZodType > ( options : {
82
+ export function zodFunction < Parameters extends ZodType > ( options : {
83
83
name : string ;
84
84
parameters : Parameters ;
85
- function ?: ( ( args : z . infer < Parameters > ) => unknown | Promise < unknown > ) | undefined ;
85
+ function ?: ( ( args : zodInfer < Parameters > ) => unknown | Promise < unknown > ) | undefined ;
86
86
description ?: string | undefined ;
87
87
} ) : AutoParseableTool < {
88
88
arguments : Parameters ;
89
89
name : string ;
90
- function : ( args : z . infer < Parameters > ) => unknown ;
90
+ function : ( args : zodInfer < Parameters > ) => unknown ;
91
91
} > {
92
92
// @ts -expect-error TODO
93
93
return makeParseableTool < any > (
0 commit comments