Documentation
¶
Overview ¶
Package fakeweather is a chat.Tool that returns synthesized weather data for a given (location, date). All values are deterministic functions of the input — there is no real weather API behind it.
Use this for demos, prototypes, integration tests, or any flow that needs a "weather tool" that produces sane, reproducible JSON without network access. NEVER use the output for real decisions.
Determinism: a request that supplies (location, date, includes) produces the same Response across runs. The seed is derived from the location string and target date.
Index ¶
- type AirQuality
- type AirQualityLevel
- type Alert
- type AlertSeverity
- type AlertType
- type Astronomy
- type Condition
- type Coordinates
- type HourlyForecast
- type Precipitation
- type PrecipitationIntensity
- type PrecipitationType
- type Request
- type Response
- type Temperature
- type TimeRange
- type Tool
- type UVIndex
- type UVLevel
- type Wind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AirQuality ¶
type AirQuality struct {
AQI int `json:"aqi"`
Level AirQualityLevel `json:"level"`
PM25 int `json:"pm2_5"`
PM10 int `json:"pm10"`
Ozone int `json:"ozone"`
Description string `json:"description"`
}
AirQuality is the AQI + breakdown.
type AirQualityLevel ¶
type AirQualityLevel string
AirQualityLevel is the US AQI qualitative scale.
const ( AirQualityGood AirQualityLevel = "Good" AirQualityModerate AirQualityLevel = "Moderate" AirQualityUnhealthyForSensitiveGroups AirQualityLevel = "Unhealthy for Sensitive Groups" AirQualityUnhealthy AirQualityLevel = "Unhealthy" AirQualityVeryUnhealthy AirQualityLevel = "Very Unhealthy" AirQualityHazardous AirQualityLevel = "Hazardous" )
These values keep generated fixtures inside the public vocabulary.
type Alert ¶
type Alert struct {
Type AlertType `json:"type"`
Severity AlertSeverity `json:"severity"` // moderate, severe, extreme
Title string `json:"title"`
Description string `json:"description"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
}
Alert is a synthesized weather alert (heat, cold, wind, storm, blizzard, typhoon).
type AlertSeverity ¶
type AlertSeverity string
AlertSeverity is the closed synthesized warning scale.
const ( AlertSeverityModerate AlertSeverity = "moderate" AlertSeveritySevere AlertSeverity = "severe" AlertSeverityExtreme AlertSeverity = "extreme" )
These values keep generated fixtures inside the public vocabulary.
type Astronomy ¶
type Astronomy struct {
Sunrise string `json:"sunrise"`
Sunset string `json:"sunset"`
Moonrise string `json:"moonrise"`
Moonset string `json:"moonset"`
MoonPhase string `json:"moon_phase"`
MoonIllumination int `json:"moon_illumination"` // 0-100
}
Astronomy holds sun + moon data, all times in HH:MM (location's local time inferred from longitude — approximate).
type Condition ¶
type Condition string
Condition is the closed weather-condition vocabulary shared by generation and the public response.
const ( ConditionBlizzard Condition = "Blizzard" ConditionClear Condition = "Clear" ConditionCloudy Condition = "Cloudy" ConditionCold Condition = "Cold" ConditionDrizzle Condition = "Drizzle" ConditionDusty Condition = "Dusty" ConditionFoggy Condition = "Foggy" ConditionFreezing Condition = "Freezing" ConditionHazy Condition = "Hazy" ConditionHot Condition = "Hot" ConditionHumid Condition = "Humid" ConditionMild Condition = "Mild" ConditionOvercast Condition = "Overcast" ConditionPartlyCloudy Condition = "Partly Cloudy" ConditionRainy Condition = "Rainy" ConditionSnowy Condition = "Snowy" ConditionStormy Condition = "Stormy" ConditionSunny Condition = "Sunny" ConditionWindy Condition = "Windy" )
These values keep generated fixtures inside the public vocabulary.
type Coordinates ¶
type Coordinates struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Elevation int `json:"elevation"`
}
Coordinates is the location's geographic anchor. Elevation in meters.
type HourlyForecast ¶
type HourlyForecast struct {
Time int64 `json:"time"`
Temperature int `json:"temperature"`
Condition Condition `json:"condition"`
Precipitation float64 `json:"precipitation"`
Humidity int `json:"humidity"`
WindSpeed float64 `json:"wind_speed"`
}
HourlyForecast is one hour of the 24-hour breakdown.
type Precipitation ¶
type Precipitation struct {
Type PrecipitationType `json:"type"` // rain, snow, sleet
Probability int `json:"probability"` // 0-100
Amount float64 `json:"amount"` // mm
Intensity PrecipitationIntensity `json:"intensity"` // light, moderate, heavy
}
Precipitation describes liquid/solid water expected for the day.
type PrecipitationIntensity ¶
type PrecipitationIntensity string
PrecipitationIntensity is the closed amount classification.
const ( PrecipitationLight PrecipitationIntensity = "light" PrecipitationModerate PrecipitationIntensity = "moderate" PrecipitationHeavy PrecipitationIntensity = "heavy" )
These values keep generated fixtures inside the public vocabulary.
type PrecipitationType ¶
type PrecipitationType string
PrecipitationType is the synthesized precipitation phase.
const ( PrecipitationRain PrecipitationType = "rain" PrecipitationSleet PrecipitationType = "sleet" PrecipitationSnow PrecipitationType = "snow" )
These values keep generated fixtures inside the public vocabulary.
type Request ¶
type Request struct {
Location string `` /* 186-byte string literal not displayed */
Date string `` /* 160-byte string literal not displayed */
IncludeHourly bool `json:"include_hourly,omitempty" jsonschema_description:"Include a 24-hour forecast. Defaults to false."`
IncludeAirQuality bool `json:"include_air_quality,omitempty" jsonschema_description:"Include AQI and pollutant concentrations. Defaults to false."`
}
Request is the tool input. Date is optional; when omitted the tool uses the current calendar date in UTC.
type Response ¶
type Response struct {
Location string `json:"location"`
Coordinates Coordinates `json:"coordinates"`
Timestamp TimeRange `json:"timestamp"`
Temperature Temperature `json:"temperature"`
Condition Condition `json:"condition"`
Description string `json:"description"`
Humidity int `json:"humidity"`
Pressure int `json:"pressure"` // hPa
Visibility int `json:"visibility"` // km
CloudCover int `json:"cloud_cover"` // 0-100
DewPoint int `json:"dew_point"`
Wind Wind `json:"wind"`
Precipitation *Precipitation `json:"precipitation,omitempty"`
AirQuality *AirQuality `json:"air_quality,omitempty"`
UVIndex UVIndex `json:"uv_index"`
Astronomy Astronomy `json:"astronomy"`
HourlyForecast []HourlyForecast `json:"hourly_forecast,omitempty"`
Alerts []Alert `json:"alerts,omitempty"`
Source string `json:"source"`
LastUpdated int64 `json:"last_updated"` // Unix seconds, equal to start of target date (deterministic)
}
Response is the synthesized weather report.
type Temperature ¶
type Temperature struct {
Value int `json:"value"`
Unit string `json:"unit"` // always "Celsius"
FeelsLike int `json:"feels_like"`
Min int `json:"min"`
Max int `json:"max"`
}
Temperature is the day's representative temperature plus its swing. Value is the daily mean (not midnight, not noon) so a date-only query gets the day's "typical" reading.
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool is a chat.Tool that synthesizes weather reports. Construct with New.
func New ¶
New builds a tool whose output is derived from its arguments alone, so an example that calls it produces the same report on every run. A real weather API would make the surrounding examples untestable and would tie them to a credential; the writer exists only to show call activity.
func (*Tool) Call ¶
func (t *Tool) Call(ctx context.Context, invocation toolcontract.Invocation) (chat.ToolOutput, error)
func (*Tool) Definition ¶
func (t *Tool) Definition() chat.ToolDefinition
func (*Tool) Unwrap ¶ added in v0.19.0
func (t *Tool) Unwrap() toolcontract.Tool
Unwrap exposes the typed input contract through tool decorators.
type UVIndex ¶
type UVIndex struct {
Value int `json:"value"`
Level UVLevel `json:"level"`
Description string `json:"description"`
}
UVIndex per WHO levels (0-11+).