Preface: Use gpt-4o-2024-08-06 specifically for response mode with json_schema (structured outputs)
Functions + json_schema is giving errors, against expectation, with chat completions playground code.
Documentation: Structured Outputs is available in two forms in the OpenAI API:
- When using function calling
- When using a
json_schema
response format
Documentation doesn’t spell out these are exclusive separate uses.
I made a function requiring two arrays sent about the same entity extraction items, where the AI must call a function to find out the class of item instead of making its own determination (is “tomato” a vegetable or fruit according to us).
The AI somewhat unexpectedly employs parallel tool calls to split the entities it asks about. I type up a response for each function call because I don’t actually have answering code.
(playground preset at this point)
- text: responds
- json_object: responds (after placing a “json” in prompt)
- json_schema: gives a UI error “NetworkError when attempting to fetch resource.”
Actual network error 500:
{
“error”: {
“message”: “The server had an error processing your request. Sorry about that! You can retry your request, or contact us through our help center at help.openai.com if you keep seeing this error. (Please include the request ID req_49e9d8106e89eb6bbebbe24c9aaf215d in your email.)”,
“type”: “server_error”,
“param”: null,
“code”: null
}
}
Since sending to the API is not blocked, and a reason not returned, I assume there’s a structure validation conflict - like the response mode turning on functions strictness, and the json output not being parsable by the tool recipient determiner (or the opposite).
Also annoying in playground: there’s a switch to go between json and plain text, but it seems to add and remove whitespace that I prohibit, making what was actually received unclear.