feat: add date-based weather forecasts and dynamic time context

This commit is contained in:
loveuer committed 2026-11-18 11:30:38 +08:00
1 parent a394f22d77
commit 975352c7d6
12 files changed
+607 -15

No files matched your search

-5
View File
@@ -12,8 +12,3 @@ type ToolFunctionDefinition struct {
Description string `json:"description"`
Parameters map[string]any `json:"parameters"`
}
// WeatherArguments 指定要查询当前天气的地点。
type WeatherArguments struct {
Location string `json:"location"`
}
+45
View File
@@ -0,0 +1,45 @@
package model
// WeatherArguments 指定地点,以及可选的预报日期范围。
type WeatherArguments struct {
Location string `json:"location"`
StartDate string `json:"start_date,omitempty"`
EndDate string `json:"end_date,omitempty"`
}
// WeatherLocations 是 Open-Meteo 的城市搜索结果,使用首个匹配项。
type WeatherLocations struct {
Results []struct {
Name string `json:"name"`
Admin1 string `json:"admin1"`
Country string `json:"country"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"results"`
}
// WeatherDailyResponse 只保留本示例使用的逐日预报字段。
type WeatherDailyResponse struct {
Daily struct {
Dates []string `json:"time"`
Codes []*int `json:"weather_code"`
MaxTemps []*float64 `json:"temperature_2m_max"`
MinTemps []*float64 `json:"temperature_2m_min"`
RainChances []*float64 `json:"precipitation_probability_max"`
} `json:"daily"`
}
// WeatherForecast 向模型返回实际匹配地点和指定日期的预报。
type WeatherForecast struct {
Location string `json:"location"`
Timezone string `json:"timezone"`
Days []WeatherDay `json:"days"`
}
type WeatherDay struct {
Date string `json:"date"`
Condition string `json:"condition"`
MinTemperatureC float64 `json:"min_temperature_c"`
MaxTemperatureC float64 `json:"max_temperature_c"`
PrecipitationChancePct float64 `json:"precipitation_probability_max_pct"`
}