Link a Tool to a Prompt

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 achieve this by creating a JSON Schema Tool and linking that to as many Prompts as you need.

Importantly, updates to this Tool defined here will then propagate automatically to all the Prompts you’ve linked it to, without having to deploy new versions of the Prompt.

Prerequisites

  • You already have a Prompt — if not, please follow our Prompt creation guide first.

Creating and linking a JSON Schema Tool

To create a reusable JSON Schema tool for your organization, follow these steps:

1

Create a new Tool file

Navigate to the homepage or sidebar and click the ‘New File’ button.

2

Choose the JSON Schema Tool type

From the available options, select Json Schema as the Tool type.

3

Give the tool a name

Form the top navigation bar, click on the Tool name, and rename to “Weather tool”

4

Define your tool’s structure

Paste the following JSON into the provided dialog to define your tool’s structure:

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}

If you choose to edit or create your own tool, you’ll need to use the universal JSON Schema syntax. When creating a custom tool, it should correspond to a function you have defined in your own code. The JSON Schema you define here specifies the parameters and structure you want the AI model to use when interacting with your function.

5

Commit this version of the Tool

Press the Commit button to commit this version of the Tool, and set it as the default version by deploying it.

7

Add Tool to the Prompt definition.

In the dropdown, go to the Link existing tool option. You should see your Weather Tool tool, click on it to link it to your editor.

8

Test that the Prompt is working with the tool

Now that your Tool is linked you can start using it. 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

Commit the Prompt

You’ve linked a Tool to your Prompt, now let’s save it. Press the Save button and name your Prompt weather-model.

10

(Optional) Update the Tool

Now that’s we’ve linked your get_current_weather tool to your Prompt, let’s try updating the base tool and see how it propagates the changes down into your saved weather-model version. Navigate back to the Tool in the sidebar and go to the Editor.

11

Update 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

Commit and deploy the Tool

Press the Commit button and then follow the steps to deloy this version of the Tool.

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 loaded as the active version. 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 Prompt.

Linked JSON Schema tool changes propagate to Prompt

When updating your Tool, remember that the change will affect all the Prompts that link to it. Be careful when making updates to not inadvertently change something you didn’t intend.