Link a JSON Schema tool

It's possible to manage tool definitions globally for your organization and re-use them across multiple projects by linking them to your model configs. You can achieve this tool re-use by first defining an instance of a JSON Schema tool in your global Tools tab. Here you can define a tool once, such as get_current_weather(location: string, unit: 'celsius' | 'fahrenheit'), and then link that to as many model configs as you need within the Editor as shown below.

Importantly, updates to the get_current_weather JSON Schema tool defined here will then propagate automatically to all the model configs you've linked it to, without having to publish new versions of the prompt.

Creating and linking a JSON Schema Tool

Prerequisites

  1. A Humanloop account - you can create one by going to our sign up page.
  2. Be on a paid plan - your organization has been upgraded from the Free tier.
  3. You already have a project created - if not, please pause and first follow our project creation guides.

๐Ÿšง

Paid feature

The Snippet tool is not available for the Free tier. Please contact us if you wish to learn more about our Enterprise plan

To create a JSON Schema tool that can be reusable across your organization, follow the following steps:

  1. Navigate to the tools tab in your organisation and select the Json Schema tool card.

  1. With the dialog open, define your tool with name, description, and parameters values. Our guide for using OpenAI Function Calling in the playground can be a useful reference in this case. We can use the get_current_weather schema in this case. Paste the following into the dialog:
{
  "name": "get_current_weather",
  "description": "Get the current weather in a given location",
  "parameters": {
    "type": "object",
    "properties": {
      "location": {
        "type": "string",
        "name": "Location",
        "description": "The city and state, e.g. San Francisco, CA"
      },
      "unit": {
        "type": "string",
        "name": "Unit",
        "enum": [
          "celsius",
          "fahrenheit"
        ]
      }
    },
    "required": [
      "location"
    ]
  }
}
  1. Press the Create button.
  2. Navigate to the Editor of your previously created project. And make sure you are using a supported model, such as gpt-3.5-turbo.

๐Ÿ“˜

Models supporting OpenAI Function calling

The current OpenAI list of supported models is:

  • gpt-4
  • gpt-4-1106-preview
  • gpt-4-0613
  • gpt-3.5-turbo
  • gpt-3.5-turbo-1106
  • gpt-3.5-turbo-0613
  1. In the Tools section of the Editor press the Add Tool button.
  2. In the dropdown, go to the Link existing tool option. You should see your get_current_weather tool, click on it to link it to your editor.

  1. Now that your tool is linked you can start using it as you would normally use an inline tool. In the Chat section, in the User input, enter "What is the weather in london?"
  2. Press the Run button.
  3. You should see the Assistant respond with the tool response and a new Tool field inserted to allow you to insert an answer. In this case, put in 22 into the tool response and press Run.

  1. The model will respond with The current weather in London is 22 degrees.
  2. You've linked a tool to your model config, now let's save it. Press the Save button and name your model config weather-model-config.
  3. Now that's we've linked your get_current_weather tool to your model config, let's try updating the base tool and see how it propagates the changes down into your saved weather-model-config config. Navigate back to the organization Tools section by clicking the Tools button in the top right of the nav bar.
  4. Click the menu dropdown button of the get_current_weather tool and press Edit.
  5. Let's update both the name, as well as the required fields. For the name, update it to get_current_weather_updated and for the required fields, add unit as a required field. The should look like this now:
{
  "name": "get_current_weather_updated",
  "description": "Get the current weather in a given location",
  "parameters": {
    "type": "object",
    "properties": {
      "location": {
        "type": "string",
        "name": "Location",
        "description": "The city and state, e.g. San Francisco, CA"
      },
      "unit": {
        "type": "string",
        "name": "Unit",
        "enum": [
          "celsius",
          "fahrenheit"
        ]
      }
    },
    "required": [
      "location",
      "unit"
    ]
  }
}
  1. Press the Save button, then the following Continue button to confirm.
  2. Your tool is now updated. Navigate back to your previous project, and open the editor. You should see the weather-model-config loaded as the active config. You should also be able to see the name of your previously linked tool in the Tools section now says get_current_weather_updated.
  3. In the Chat section enter in again, What is the weather in london?, and press Run again.
  4. You should see the updated tool response, and how it now contains the unit field.

๐Ÿšง

Linked JSON Schema tool changes propogate to saved model configs

When updating your organization-level JSON Schema tools, remember that the change will affect all the places you're previously linked the tool. Be careful when making updates to not inadvertently change something you didn't intend.


Whatโ€™s Next

Explore our other tools such as the Snippet or Pinecone Search tool