feat(weather): default to today only, add days parameter for multi-day requests
get_weather now returns 1 day by default (today) instead of a full 7-day forecast. A new optional `days` parameter (1–8) lets the model request more days when the user explicitly asks for a weekly forecast or specific date range. Tool description updated to guide the model accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -560,9 +560,9 @@ _CORE_TOOLS = [
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"description": (
|
||||
"Get the 7-day weather forecast. Pass a city/region name to look up any location, "
|
||||
"or omit to get the user's configured home/work locations. "
|
||||
"Returns temperature, precipitation, and conditions for each day."
|
||||
"Get the weather forecast. By default returns today only — use days=7 when the user "
|
||||
"explicitly asks for a multi-day forecast or 'this week'. "
|
||||
"Pass a city/region name to look up any location, or omit to get the user's configured home/work locations."
|
||||
),
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
@@ -573,7 +573,14 @@ _CORE_TOOLS = [
|
||||
"City, region, or country to look up — e.g. 'Portland, Oregon', 'Tokyo', 'home', 'work'. "
|
||||
"Use 'home' or 'work' to get the user's saved locations. Omit for all saved locations."
|
||||
),
|
||||
}
|
||||
},
|
||||
"days": {
|
||||
"type": "integer",
|
||||
"description": (
|
||||
"Number of days to return (1–8). Default 1 (today only). "
|
||||
"Use 7 or 8 when the user asks for a weekly forecast or multiple days."
|
||||
),
|
||||
},
|
||||
},
|
||||
"required": [],
|
||||
},
|
||||
@@ -1917,6 +1924,7 @@ async def execute_tool(
|
||||
from fabledassistant.services.briefing_pipeline import _get_temp_unit
|
||||
from datetime import timezone as _tz
|
||||
location = (arguments.get("location") or "").strip()
|
||||
num_days = max(1, min(8, int(arguments.get("days") or 1)))
|
||||
temp_unit = await _get_temp_unit(user_id)
|
||||
|
||||
def _apply_unit(days: list[dict]) -> list[dict]:
|
||||
@@ -1935,7 +1943,7 @@ async def execute_tool(
|
||||
try:
|
||||
lat, lon, label = await geocode(location)
|
||||
raw = await _fetch_open_meteo(lat, lon)
|
||||
days = _apply_unit(parse_forecast(raw))
|
||||
days = _apply_unit(parse_forecast(raw))[:num_days]
|
||||
return {"success": True, "data": {"locations": [{
|
||||
"location_key": "query",
|
||||
"location_label": label,
|
||||
@@ -1951,7 +1959,7 @@ async def execute_tool(
|
||||
if location.lower() not in ("all", ""):
|
||||
locations = [loc for loc in locations if loc["location_key"] == location.lower()]
|
||||
locations = [
|
||||
{**loc, "days": _apply_unit(loc.get("days", [])), "temp_unit": temp_unit}
|
||||
{**loc, "days": _apply_unit(loc.get("days", []))[:num_days], "temp_unit": temp_unit}
|
||||
for loc in locations
|
||||
]
|
||||
return {"success": True, "data": {"locations": locations}}
|
||||
|
||||
Reference in New Issue
Block a user