-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model seems to ignore .optional()
fields, and instead uses fasly values such as 0, empty strings etc'
#1180
Comments
According to the docs, the model treats all fields as required, but it is recommended to use a union with null to achieve this: https://platform.openai.com/docs/guides/structured-outputs#all-fields-must-be-required This sounds like zod's |
Thanks for reporting! This sounds like an issue with the underlying OpenAI API and not the SDK, so I'm going to go ahead and close this issue. When you use Would you mind reposting at community.openai.com? |
.optional()
fields, and instead uses nullary values, empty strings etc'.optional()
fields, and instead uses fasly values such as 0, empty strings etc'
This may be the line of code that converts an optional property to required. I don't see any code for making the property nullable. In my testing I don't see the output schema nullable either. |
also just to be compliant with the |
This commit adds a warning when .optional() is used in schemas for OpenAI API Structured Outputs, recommending the use of .nullable() instead. - Added warning in optional.ts that triggers when openaiStrictMode is true - Added test to verify warning behavior Fixes openai#1180
As discussed above, the API doesn't allow optional fields and the docs recommend nullable fields as a workaround. The SDK already supports Zod's (I briefly thought about instead making |
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
Model seems to ignore
.optional()
fields, and instead uses nullary values, empty strings etc'I'm not sure if it's a library issue or chatgpt model issue.
To Reproduce
I suspect this is a KI or an upstream problem, but let me know if not I'll send a repro
Code snippets
No response
OS
ubuntu
Node version
22.7.0
Library version
4.57.0
The text was updated successfully, but these errors were encountered: