The JSON schema you provided seems to be well-structured and adheres to the JSON schema standards. However, it’s missing the root structure documented for the OpenAI API’s response_format parameter.
{
"type": "json_schema",
"json_schema": {
"name": "your_schema_name",
"schema": {
// Your JSON Schema definition
},
"strict": true // or false
}
}
Here’s how you can wrap your schema to meet the OpenAI API requirements:
{
"type": "json_schema",
"json_schema": {
"name": "table_component",
"schema": {
"type": "object",
"properties": {
"table": {
"type": "object",
"properties": {
"name": {"type" : "string"},
"columns": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name" : {"type" : "string"},
"type" : {"type" : "string"}
},
"required" : ["name", "type"],
"additionalProperties" : False
}
}
},
"required": ["name", "columns"],
"additionalProperties" : False
},
"component" : {"type": "object"}
},
"required" : ["component","table"],
"additionalProperties" : False
},
"strict": true
}
}
This structure now meets the OpenAI API requirements for the response_format parameter.
Let’s break down the schema:
-
Root Level: The root level of the schema is an object, as required. It includes the
typefield set to"json_schema", thejson_schemafield containing the schema definition, and thestrictfield set totrue. -
json_schemaLevel: This level includes thenameof your schema, theschemadefinition, and thestrictfield. Thestrictfield is set totrue, meaning all properties are required. -
schemaLevel: This level defines the actual JSON schema. It’s an object with two properties:tableandcomponent. Both properties are required, as specified in therequiredfield. -
tableLevel: This level is an object with two properties:nameandcolumns. Both properties are required. Thenameis a string, andcolumnsis an array of objects. -
columnsLevel: This level is an array of objects. Each object has two properties:nameandtype. Both properties are required and are strings. -
componentLevel: This level is an object. However, it doesn’t specify any properties, so it can contain any valid JSON object.
Remember, the strict field being set to true means that all properties are required. An object like "component" being empty makes no sense for a structured schema. If you want to make some properties optional or free-running, you would need to set strict to false and adjust the required fields accordingly.
(not a question that gpt-4o can answer correctly.)
Two people sending the exact same schemas??