fakeweather

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

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 AlertType

type AlertType string

AlertType identifies a synthesized warning category.

const (
	AlertCold    AlertType = "cold"
	AlertHeat    AlertType = "heat"
	AlertSnow    AlertType = "snow"
	AlertStorm   AlertType = "storm"
	AlertTyphoon AlertType = "typhoon"
	AlertWind    AlertType = "wind"
)

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 TimeRange

type TimeRange struct {
	Start int64 `json:"start"`
	End   int64 `json:"end"`
}

TimeRange is a [start, end) Unix-second window covering the target date.

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool is a chat.Tool that synthesizes weather reports. Construct with New.

func New

func New(writer io.Writer) *Tool

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+).

type UVLevel

type UVLevel string

UVLevel is the WHO UV-index qualitative scale.

const (
	UVLow      UVLevel = "Low"
	UVModerate UVLevel = "Moderate"
	UVHigh     UVLevel = "High"
	UVVeryHigh UVLevel = "Very High"
	UVExtreme  UVLevel = "Extreme"
)

These values keep generated fixtures inside the public vocabulary.

type Wind

type Wind struct {
	Speed     float64 `json:"speed"`
	Unit      string  `json:"unit"` // always "km/h"
	Direction string  `json:"direction"`
	Degree    int     `json:"degree"`
	Gust      float64 `json:"gust"`
}

Wind in km/h.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL