How can I define my structured output to be dynamic?
I want my response schema to be different depending on what GPT decides.
Look at my response_schema below.
{
"type": "json_schema",
"json_schema": {
"name": "my_response",
"strict": True,
"schema": {
"type": "object",
"properties": {
"my_response": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The section's title.",
},
"component": {
"type": "string",
"enum": ["text", "image"],
"description": "Choose text if this section should have text. Choose image if it should have an image."
},
"body": {
...
},,
},
"required": ["title", "component", "body"],
"additionalProperties": False,
},
},
"required": ["my_response"],
"additionalProperties": False,
},
},
}
Where if component is of type “text” I want “body” to be:
{
"type": "object",
"properties": {
"content": {
"type": "string"
}
}
}
}
But if component is of type “image” I want “body” to be:
{
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
}
}