Hello, I have a an abstract function that has a few required parameters, but also may have multiple additional parameters, which are passed through **kwargs depending on the use case. I want my Assistant API to use this function as a tool, and it works fine but with required parameters only, it simply always ignores the **kwargs. Does Assistant API tool support this? I have described it my current JSON schema under properties as follows:
"additionalParameters": {
"type": "object",
"description": "Additional parameters as required by the function (e.g., length)",
"additionalProperties": true
}
I couldn’t find any documentation describing this explicitly. Please help.
Hi @dilshat
This should be achievable by including another key called “additionalProperties” inside the parameters object of the existing schema.
Here’s a sample of how it’d look like:
tools=[
{
"type": "function",
"function": {
"name": "get_current_temperature",
"description": "Get the current temperature for a specific location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g., San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["Celsius", "Fahrenheit"],
"description": "The temperature unit to use. Infer this from the user's location."
}
},
"additionalProperties": {
"description": "Additional arguments that can be of any type"
},
"required": ["location", "unit"]
}
}
}
]
I believe that you’d also need to list and describe the keys that "additionalProperties" takes and what values they can be assigned. This will help the model/assistant “decide” better when/whether to use them.