Creating a Tool

You can declare a new function within the Tools panel in a Prompt by selecting the Add Tool button.

You will be presented with a new function for which you can define name and JSON schema.

Here is an example of a JSON schema for a function get_current_weather that declares the fields location (string)and unit (string):

{
  "type": "object",
  "properties": {
    "unit": {
      "type": "string",
      "description": "The temperature unit, e.g. Celsius"
    },
    "location": {
      "type": "string",
      "description": "The city and state, e.g. San Francisco, CA"
    }
  },
  "required": [
    "location",
    "unit"
  ]
}

📘

The object defined here is based on JSON Schema. This framework allows for extensible definition that fit your ideal function definition.

Field Details

Type

Use here any of the valid JSON types: object, string, integer, number, array, etc...

The top-level type will most commonly be an object holding other properties.

📘

Learn more about all JSON types in the JSON Schema definition.

Properties

Properties are definition of fields within an object. Here you can define any new variable.

Nested properties are allowed.

Required

The required array within an object defines which fields must be entered for a JSON payload to be validated.