-
-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Description
TanStack AI version
0.2.0
Framework/Library version
vanilla 0.2.0
Describe the bug and the steps to reproduce it
Structured output doesn't support for unions:
chat({
adapter: openaiText("gpt-4o-mini"),
messages: [{ role: "user", content: "..." }],
outputSchema: z.object({
u: z.union([
z.object({ a: z.string() }),
z.object({ b: z.number() })
]),
}),
});
// throw {
// message: "Invalid schema for response_format 'structured_output': In context=('properties', 'u', 'anyOf', '0'), 'additionalProperties' is required to be supplied and to be false.",
// type: "invalid_request_error",
// param: "text.format.schema",
// code: "invalid_json_schema",
// }The issue seems to come from openAI format converter:
| export function makeOpenAIStructuredOutputCompatible( |
It doesn't handle the JSON schema
anyOf object like:
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Metadata
Metadata
Assignees
Labels
No labels
{ "anyOf": [ // ... ] }