Example: Weather Agent
A simple agent talking to the weather site
In this tutorial, we’ll explore how to create and use a simple WeatherLogger
agent. This agent can check the current weather and log the info to a human-readable format.
You can play around with this example at Jupyter notebook.
WeatherLogger
class
This is a straightforward implementation of the Tool
class, designed to perform two primary operations: checking the weather (observation) and logging the information (action).
Pretty trivial, as you can see.
Communication with LLM
The interesting part though is not really the ability to use weather API and write to files, but to use this class to give an LLM a new skill. All we have to do is get the schema of the tool actions and observations and give them to our LLM like this:
As you can see, the schema
object lists all actions we have with their parameters and descriptions.
Now that we have this info, we can implement a simple scenario:
- We inform the AI about the tools (in our case,
weather
andlog
) that it can use. - We give it a task to check and describe weather in a given city.
First things first: We start with a prompt. As you can see, it contains the schema of the tool and the instructions on how to respond.
Now, we add a couple of helper functions to make the process of interacting with the AI easier.
The entire process after this looks as follows:
- Update the list of messages
- Ask the AI for the next step
- Execute the next step
- Repeat
- …
- Profit!
And here we are, with a beautiful poem about the weather in Paris inside the weather.txt
:
What’s next?
- Play around with this example at Jupyter notebook.
- Look at more realistic example of a SeleniumBrowser tool implementation.
- Dive into an elaborated implentation of the Desktop tool from the AgentDesk project, which adds the
Tool
sause on top of the Agentd-powered VMs.