Want to let Yumi check your local weather, look at your calendar, or play your favorite Spotify playlist?
You can easily write custom tools in Python and expose them directly to her LangGraph agent. Follow this tutorial to build one.
Step 1: Write Your Python Tool
Open the tools initialization file or add a new file inside:
src/yumi/tools/
Let's write a simple Weather Checker tool using standard LangChain @tool decorators:
from langchain_core.tools import tool
import aiohttp
@tool
async def get_current_weather(location: str) -> str:
"""Fetch the current temperature and weather description for a given city location.
Args:
location: The name of the city, e.g. "Tokyo" or "New York".
"""
try:
# We can perform real HTTP requests inside our tool functions!
url = f"https://wttr.in/{location}?format=j1"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
if response.status == 200:
data = await response.json()
temp = data["current_condition"][0]["temp_C"]
desc = data["current_condition"][0]["weatherDesc"][0]["value"]
return f"The weather in {location} is currently {temp}°C with {desc}."
return "Failed to fetch weather data."
except Exception as e:
return f"Weather lookup failed: {e}"
Step 2: Register Your Tool
To make Yumi's LLM aware of the weather tool, add it to the tools list inside src/yumi/tools/__init__.py:
from yumi.tools.time_tool import get_current_time
from yumi.tools.weather_tool import get_current_weather # Import your new tool
# Expose as a combined list
tools = [
get_current_time,
get_current_weather, # Register it in the active list!
]
Step 3: Run and Test
That's it! When you run yumi wake-up and start your conversation:
- Ask: "Hey Yumi, what is the weather like in Paris?"
- Yumi's LLM will automatically decide to execute the
get_current_weathertool withlocation="Paris". - The backend runs your local python request, passes the result back, and she speaks the answer with a matching smile!
Proceed to the Integration section to see how to connect other clients to Yumi!