getting this error in the playground, what am i missing?
{
"name": "get_name",
"description": "get the person name",
"strict": true,
"parameters": {
"type": "object",
"properties": {
"person_name": {
"type": "string",
"description": "The person name if available"
},
"has_person_name": {
"type": "boolean",
"description": "if the user has given its name"
}
},
"additionalProperties": false,
"required": [
"has_person_name"
]
}
}
Entering this in here:
## Add response format
Use a JSON schema to define the structure of the model's response format. [Learn more.](https://platform.openai.com/docs/guides/structured-outputs)
{
"name": "get_name",
"description": "get the person name",
"strict": true,
"schema": {
"type": "object",
"properties": {
"person_name": {
"type": ["string", "null"],
"description": "The person name if available"
},
"has_person_name": {
"type": "boolean",
"description": "if the user has given its name"
}
},
"additionalProperties": false,
"required": [
"has_person_name",
"person_name"
]
}
}
This works fine for me. Explanation:
Changed parameters to schema
When dealing with strict schema, you have to provide all the fields in the required list, so I included person_name
Since you want person_name to be “optional”, I added "type": ["string", "null"]
I suspect the solution was reached in the intervening two-and-a-half months.
An “I have the same problem” is likely someone that does not have the same problem from the same cause. More information would be needed about what is being attempted.
ok here is some more information i am trying to get Structured Output using the gpt-4o version 2024-08-06 and the schema which is being passed is the following -
I have reviewed the attached image, with an improbably-large function.
The first flaw that I can see is the inclusion of a kwargs key in the API requesst. You seem to have used this to contain the API parameter “tools”. However, tools is the first-level parameter that must be passed to the API.
Then, the keyword strict that is meant to bring about an enforced structured schema is at the incorrect nesting level. This should be at the root level within the function schema, just above the “type:function” level.
Finally, the defs may have hidden refs, or they may be used improperly, within or past the obfuscation of values. It is hard to tell. The unpacking of a schema into AI-placed typescript-like function language by the API is rather simple, and cannot handle the complete breadth of JSON schema, unlike an API response to a user, where the schema itself is given to the AI as a response method. I would unravel this entirely to an unreferenced function and see if it still makes sense.
Hopefully this will help you out in constructing a tools parameter for the API, where a function is indicated as strict in the correct manner, and therefore all fields are mandatory and must be placed in the required list also, along with placing additioonalProperties:false for each nest level of properties.