Working with your local tools
Decorate your existing functions
import requests
from toolhouse import Toolhouse
from anthropic import Anthropic
client = Anthropic(api_key="YOUR_API_KEY")
MODEL = "claude-3-5-sonnet-20240620"
th = Toolhouse(provider="anthropic")
# The parameter must match the name of the tool in your tool definition
@th.register_local_tool("get_current_weather")
def get_weather_forecast(
# These arguments must match the name of the parameters
# in your tool definition
latitude: float,
longitude: float) -> str:
url = f"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&hourly=temperature_2m&forecast_days=1"
response = requests.get(url)
if response.status_code == 200:
return response.text
else:
return f"Error: {response.status_code} - {response.text}"Pass your local tools
Overriding cloud tools
Treat tool definitions as prompts
Last updated