openai-function-calling
openai-function-calling copied to clipboard
Generate the `required` list for function parameters
Overview of Feature
When generating the JSON schema for a function, some parameters might have default values. In the case where at least one parameter has a default value, we should populate required in the JSON schema with all required parameters.
Why add this feature?
So GPT can skip some parameters if it thinks they should not be set.
Acceptance Criteria to Meet
Given this function:
def get_current_weather(location, unit="fahrenheit"):
The generated JSON schema should be:
{
"name": "get_current_weather",
"description": "Get the current weather and return a summary.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string"
},
"unit": {
"type": "string"
}
},
"required": ["location"] <----------------------
}
}