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:
Give the tool a name
Form the top navigation bar, click on the Tool name, and rename to “Weather tool”
Define your tool’s structure
Paste the following JSON into the provided dialog to define your tool’s structure:
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.
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.
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.
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
.
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
.
(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.
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:
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.
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.
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.