Last active
October 26, 2025 14:43
-
-
Save vman/414204505a8d7a7eecd2ac8d92d7cb03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "@typespec/http"; | |
| import "@microsoft/typespec-m365-copilot"; | |
| using TypeSpec.Http; | |
| using TypeSpec.M365.Copilot.Actions; | |
| /* -------- Geocoding (city -> coords) -------- */ | |
| @service | |
| @server("https://geocoding-api.open-meteo.com", "Open-Meteo Geocoding") | |
| @actions(#{ | |
| nameForHuman: "City Search", | |
| descriptionForHuman: "Resolve a city name to coordinates", | |
| descriptionForModel: "Search city and return top match with latitude/longitude" | |
| }) | |
| namespace GeoAPI { | |
| @route("/v1/search") | |
| @get | |
| @card(#{ dataPath: "$.results[0]", file: "adaptiveCards/location-card.json", properties: #{ title: "Location" } }) | |
| @doc("Search for a city and return the top geocoding match with latitude/longitude.") | |
| op searchCity( | |
| @query name: string, | |
| @query count?: int32 = 1, | |
| @query language?: string = "en" | |
| ): GeoResult; | |
| model GeoResult { | |
| results?: GeoPlace[]; | |
| } | |
| model GeoPlace { | |
| id?: int32; | |
| name: string; | |
| latitude: float64; | |
| longitude: float64; | |
| country?: string; | |
| admin1?: string; | |
| } | |
| } | |
| /* -------- Weather (coords -> current weather) -------- */ | |
| @service | |
| @server("https://api.open-meteo.com", "Open-Meteo Forecast") | |
| @actions(#{ | |
| nameForHuman: "Open-Meteo Weather", | |
| descriptionForHuman: "Get current temperature and wind for coordinates", | |
| descriptionForModel: "Fetch current_weather for given lat/lon" | |
| }) | |
| namespace WeatherAPI { | |
| @route("/v1/forecast") | |
| @get | |
| @card(#{ dataPath: "$", file: "adaptiveCards/weather-card.json", properties: #{ title: "$.location" } }) | |
| @doc("Get weather for the given latitude/longitude. Supports 'hourly', 'daily', 'current' datasets and 'timezone'.") | |
| op getWeather( | |
| @query latitude: float64, | |
| @query longitude: float64, | |
| // Comma-separated list of hourly variables, e.g., "temperature_2m,relative_humidity_2m" | |
| @query hourly?: string, | |
| // Comma-separated list of daily variables, e.g., "temperature_2m_max,temperature_2m_min" | |
| @query daily?: string, | |
| // Comma-separated list of current variables, e.g., "temperature_2m,wind_speed_10m" | |
| @query current?: string, | |
| // Timezone for timestamps; "auto" uses the location-based timezone | |
| @query timezone?: string = "auto", | |
| // Friendly label to show on the card (e.g., "Pune, IN") | |
| @query location?: string | |
| ): WeatherResult; | |
| model WeatherResult { | |
| location?: string; | |
| timezone?: string; | |
| /** New API shape for current data. Properties depend on 'current' selection. */ | |
| current?: Record<unknown>; | |
| /** New API shape for hourly data. Properties depend on 'hourly' selection. */ | |
| hourly?: Record<unknown>; | |
| /** New API shape for daily data. Properties depend on 'daily' selection. */ | |
| daily?: Record<unknown>; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment