I have a function with a parameter of dictionary type (with untyped key and value). This is what the tool definition looks like
{
"type": "function",
"function": {
"name": "example_fn",
"strict": True,
"parameters": {
"properties": {
"param_1": {
"title": "Param 1",
"type": "object",
"additionalProperties": False,
}
},
"title": "example_fn",
"type": "object",
"additionalProperties": False,
"required": ["param_1"],
},
"description": "example_fn",
},
}
however, if I pass this to the api call, i get the error
BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema for function 'example_fn': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Extra required key 'param_1' supplied.", 'type': 'invalid_request_error', 'param': 'tools[0].function.parameters', 'code': 'invalid_function_parameters'}}
I believe this happens because the JSON schema of an object without any defined properties (like the one right below) is unsupported, even though the docs make no mention of this
{
"title": "Param 1",
"type": "object",
"additionalProperties": False,
}
In fact, even if I tried to further type the dictionary, like this tool def
{
"type": "function",
"function": {
"name": "example_fn",
"strict": True,
"parameters": {
"properties": {
"param_1": {
"title": "Param 1",
"type": "object",
'additionalProperties': {'type': 'integer'},
}
},
"title": "example_fn",
"type": "object",
"additionalProperties": False,
"required": ["param_1"],
},
"description": "example_fn",
},
}
It still gets rejected by the api and throws the same error.
The only workaround is to actually leave an empty “required”
{
"type": "function",
"function": {
"name": "example_fn",
"strict": True,
"parameters": {
"properties": {
"param_1": {
"title": "Param 1",
"type": "object",
"additionalProperties": False,
}
},
"title": "example_fn",
"type": "object",
"additionalProperties": False,
"required": [],
},
"description": "example_fn",
},
}
which is puzzling because the docs clearly state that “required” must include all the fields.
Please let me know if this is a bug or expected behavior