Link a JSON Schema Tool

Managing and versioning a Tool seperately from your Prompts

It’s possible to re-use tool definitions them across multiple Prompts. You achieve this by having a Prompt file which defines a JSON schema, and linking them to your Prompt.

You can achieve this 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.

Prerequisites

  • A Humanloop account - you can create one by going to our sign up page.
  • Be on a paid plan - your organization has been upgraded from the Free tier.
  • You already have a Prompt — if not, please follow our Prompt creation guide first.

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

Creating and linking a JSON Schema Tool

Paid Feature

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

1

Create a Tool file

Click the ‘New File’ button on the homepage or in the sidebar.

2

Select the Json Schema Tool type

3

Define your tool

Set the name, description, and parameters values. Our guide for using Tool Calling in the Prompt Editor 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:

1{
2 "name": "get_current_weather",
3 "description": "Get the current weather in a given location",
4 "parameters": {
5 "type": "object",
6 "properties": {
7 "location": {
8 "type": "string",
9 "name": "Location",
10 "description": "The city and state, e.g. San Francisco, CA"
11 },
12 "unit": {
13 "type": "string",
14 "name": "Unit",
15 "enum": ["celsius", "fahrenheit"]
16 }
17 },
18 "required": ["location"]
19 }
20}
4

Press the Create button.

6

Add Tool to the Prompt definition.

8

Test that the Prompt is working with the tool

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?”

Press the Run button.

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.

The model will respond with The current weather in London is 22 degrees.

9

Save the Prompt

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.

10

(Optional) Update the Tool

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 Tools in the sidebar and go to the Editor.

11

Change the tool.

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:

1{
2 "name": "get_current_weather_updated",
3 "description": "Get the current weather in a given location",
4 "parameters": {
5 "type": "object",
6 "properties": {
7 "location": {
8 "type": "string",
9 "name": "Location",
10 "description": "The city and state, e.g. San Francisco, CA"
11 },
12 "unit": {
13 "type": "string",
14 "name": "Unit",
15 "enum": ["celsius", "fahrenheit"]
16 }
17 },
18 "required": ["location", "unit"]
19 }
20}
12

Save the Tool

Press the Save button, then the following Continue button to confirm.

Your tool is now updated.

13

Try the Prompt again

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.

In the Chat section enter in again, What is the weather in london?, and press Run again.

14

Check the response

You should see the updated tool response, and how it now contains the unit field. Congratulations, you’ve successfully linked a JSON Schema tool to your model config.

Linked JSON Schema tool changes propagate to saved model configs

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