I’m using a class of
class Food(BaseModel):
food: Optional[str] = None
amount: Optional[str] = None
list_of_stores: Optional[List[int]] = None
class Recipe(BaseModel):
list_of_foods: Optional[List[Food]] = None
and i pass it to the function
type_to_response_format_param
to format the json for my batch api jsonl request. which ends up being
{'type': 'json_schema', 'json_schema': {'schema': {'$defs': {'Food': {'properties': {'food': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'title': 'Food'}, 'amount': {'anyOf': [{'type': 'string'}, {'type': 'null'}], 'title': 'Amount'}, 'list_of_stores': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'type': 'null'}], 'title': 'List Of Stores'}}, 'title': 'Food', 'type': 'object', 'additionalProperties': False, 'required': ['food', 'amount', 'list_of_stores']}}, 'properties': {'list_of_foods': {'anyOf': [{'items': {'$ref': '#/$defs/Food'}, 'type': 'array'}, {'type': 'null'}], 'title': 'List Of Foods'}}, 'title': 'Recipe', 'type': 'object', 'additionalProperties': False, 'required': ['list_of_foods']}, 'name': 'Recipe', 'strict': True}}
yet i continually run into this response error.
{"response": {"status_code": 400, "request_id": "9ab29cc692da4f48ce8a487235631664", "body": {"error": {"message": "Invalid schema for response_format 'Recipe': None is not of type 'object', 'boolean'.", "type": "invalid_request_error", "param": "response_format", "code": null}}}, "error": null}