openai-function-calling icon indicating copy to clipboard operation
openai-function-calling copied to clipboard

Generate the `required` list for function parameters

Open minhduc0711 opened this issue 1 year ago • 0 comments

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"]   <----------------------
  }
}

minhduc0711 avatar May 16 '24 15:05 minhduc0711