openai / openai-node

Official JavaScript / TypeScript library for the OpenAI API
https://www.npmjs.com/package/openai
Apache License 2.0
7.97k stars 870 forks source link

Make it possible to change the $ref strategy of zod-to-json-schema #1134

Open FredrikNoren opened 1 month ago

FredrikNoren commented 1 month ago

Confirm this is a feature request for the Node library and not the underlying OpenAI API.

Describe the feature or improvement you're requesting

The "extract-to-root" strategy is not working for my types, but I tried changing the strategy to "none" which seems to work. It would be nice to be able to just pass down which strategy to use through zodFunction

Additional context

No response

jovermier commented 5 days ago

I have tested with the default extract-to-root and none with some surprising results. For a complex zod schema using extract-to-root schema uses 3 times as many input tokens than none. Your mileage may vary if using on simple schema. I have not observed any downsides when using none.