Weather Chatbot
Learn how to build a Weather Chatbot using Latitude and custom tools.
Overview
In this example, we will create a Weather Chatbot that can provide weather information based on user queries. The chatbot will use a custom tool to fetch weather data from an external API.
Prompt
Step-by-step guide
Related documentation:
Custom Tools
You can create custom tools to extend the capabilities of your chatbot. In this example, we will create a tool that fetches weather data from a public API.
This tool fetches weather data from the OpenWeatherMap API based on the provided location. It returns the location name, temperature, and weather description.
Prompt
Now, let’s create a prompt that uses this tool.
First, we need to define the tool structure in the prompt so that the AI model can understand how to use it.
Each tool is defined with a name, and must include a description
and parameters
following the JSON schema format. Read more about Tools for more information
Now, we just need to add the prompt instructions!
Connecting the prompt with your code
Now, let’s run this prompt from your code using your tool!
Testing the prompt in the Playground
You tool only lives in your codebase, so it can be run everytime you call your prompt via the SDK! However, from Latitude’s Playground we do not have access to your custom tool, so we cannot run it directly. In this case, running the prompt in the Playground will stop and let you add a mocked response for the tool call to test the rest of your prompt.