nexusbert commited on
Commit
27fd445
·
1 Parent(s): 69b04b9

Document weather endpoints and remove sports API

Browse files
Files changed (3) hide show
  1. DEPLOYMENT.md +18 -4
  2. SYSTEM_OVERVIEW.md +44 -0
  3. app/main.py +0 -14
DEPLOYMENT.md CHANGED
@@ -12,14 +12,25 @@
12
 
13
  Set these in your HuggingFace Space settings (Settings → Variables and secrets):
14
 
15
- 1. **WEATHER_API_KEY** (Optional)
16
- - Default provided in code
17
  - Get from: https://www.weatherapi.com/
18
 
19
  2. **EXPERT_MODEL_NAME** (Optional)
20
  - Default: `Qwen/Qwen1.5-1.8B`
21
  - Can override if needed
22
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ## Deployment Steps
24
 
25
  ### 1. Stage Files for Commit
@@ -72,8 +83,11 @@ git push origin main
72
  - Should return a JSON status message indicating the Aglimate backend is running.
73
 
74
  2. **Test Endpoints**:
75
- - `/ask` - Test multilingual farming Q&A
76
- - `/advise` - Test multimodal climate-resilient advisory (text + optional photo + GPS)
 
 
 
77
 
78
  ### Expected Behavior
79
 
 
12
 
13
  Set these in your HuggingFace Space settings (Settings → Variables and secrets):
14
 
15
+ 1. **WEATHER_API_KEY** (Required for weather features)
 
16
  - Get from: https://www.weatherapi.com/
17
 
18
  2. **EXPERT_MODEL_NAME** (Optional)
19
  - Default: `Qwen/Qwen1.5-1.8B`
20
  - Can override if needed
21
 
22
+ 3. **WEATHER_FORECAST_DAYS** (Optional)
23
+ - Default: `3`
24
+ - Controls default forecast horizon for internal weather summaries.
25
+
26
+ 4. **WEATHER_AQI** (Optional)
27
+ - Default: `yes`
28
+ - Set to `no` to disable air quality data in WeatherAPI responses used internally.
29
+
30
+ 5. **WEATHER_ALERTS** (Optional)
31
+ - Default: `yes`
32
+ - Controls whether alerts are requested from WeatherAPI in internal calls.
33
+
34
  ## Deployment Steps
35
 
36
  ### 1. Stage Files for Commit
 
83
  - Should return a JSON status message indicating the Aglimate backend is running.
84
 
85
  2. **Test Endpoints**:
86
+ - `/ask` - Multilingual farming Q&A
87
+ - `/advise` - Multimodal climate-resilient advisory (text + optional photo + GPS)
88
+ - `/weather/current` - Direct realtime weather + AQI
89
+ - `/weather/forecast` - Forecast + alerts for a location
90
+ - `/weather-alerts` - Alerts-only view for climate risk UIs
91
 
92
  ### Expected Behavior
93
 
SYSTEM_OVERVIEW.md CHANGED
@@ -132,6 +132,50 @@ Aglimate addresses these challenges by providing:
132
  4. **Output**
133
  - JSON response: `{ answer, session_id, latitude, longitude, used_image, model_used }`
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  ## 4. Technologies Used
136
 
137
  ### 4.1 Backend Framework & Infrastructure
 
132
  4. **Output**
133
  - JSON response: `{ answer, session_id, latitude, longitude, used_image, model_used }`
134
 
135
+ ---
136
+
137
+ ### 3.3 Climate & Weather Data APIs – `/weather/*`
138
+
139
+ To support climate-first decision making and give frontend engineers clear integration points, Aglimate exposes a set of WeatherAPI-backed endpoints:
140
+
141
+ - **`GET /weather/current`**
142
+ - **Inputs**: `q` (free query), or `state`, or `lat`+`lon`; optional `aqi`.
143
+ - **Output**: Raw WeatherAPI `current.json` (realtime weather + optional air quality).
144
+
145
+ - **`GET /weather/forecast`**
146
+ - **Inputs**: same `q` / `state` / `lat`+`lon`; `days` (1–14), `alerts`, `aqi`.
147
+ - **Output**: Raw `forecast.json` (multi-day forecast + alerts + AQI).
148
+
149
+ - **`GET /weather-alerts`**
150
+ - **Inputs**: `q` / `state` / `lat`+`lon`.
151
+ - **Output**: `{ location, alerts }` extracted from `forecast.json` for UI alert displays.
152
+
153
+ - **`GET /weather/history`**
154
+ - **Inputs**: `q` / `state` / `lat`+`lon`, `dt`, optional `end_dt`, `hour`, `aqi`.
155
+ - **Output**: Raw `history.json` for past climate/condition analysis.
156
+
157
+ - **`GET /weather/marine`**
158
+ - **Inputs**: `q` or `lat`+`lon`, `days` (1–7), `tides`.
159
+ - **Output**: Raw `marine.json` (marine + tide data where available).
160
+
161
+ - **`GET /weather/future`**
162
+ - **Inputs**: `q` / `state` / `lat`+`lon`, `dt` (future date).
163
+ - **Output**: Raw `future.json` (3-hourly forecast for future date).
164
+
165
+ - **`GET /weather/timezone`**
166
+ - **Inputs**: `q` / `state` / `lat`+`lon`.
167
+ - **Output**: Raw `timezone.json` (time zone + local time data).
168
+
169
+ - **`GET /weather/search`**
170
+ - **Inputs**: `q` (partial city/zip/etc.).
171
+ - **Output**: Raw `search.json` (location suggestions for UI autocompletes).
172
+
173
+ - **`GET /weather/ip`**
174
+ - **Inputs**: optional `ip` (falls back to `auto:ip`).
175
+ - **Output**: Raw `ip.json` (IP-based location lookup).
176
+
177
+ These endpoints are designed as thin pass-throughs over WeatherAPI, so frontend engineers can call them directly or use their outputs inside richer Aglimate views.
178
+
179
  ## 4. Technologies Used
180
 
181
  ### 4.1 Backend Framework & Infrastructure
app/main.py CHANGED
@@ -361,20 +361,6 @@ def weather_astronomy(
361
  raise HTTPException(status_code=502, detail=f"WeatherAPI request failed: {e}")
362
 
363
 
364
- @app.get("/weather/sports")
365
- def weather_sports(q: str):
366
- if not config.WEATHER_API_KEY:
367
- raise HTTPException(status_code=500, detail="WEATHER_API_KEY is not configured")
368
- url = "http://api.weatherapi.com/v1/sports.json"
369
- params = {"key": config.WEATHER_API_KEY, "q": q}
370
- try:
371
- resp = requests.get(url, params=params, timeout=10)
372
- resp.raise_for_status()
373
- return resp.json()
374
- except Exception as e:
375
- raise HTTPException(status_code=502, detail=f"WeatherAPI request failed: {e}")
376
-
377
-
378
  @app.get("/weather/ip")
379
  def weather_ip(ip: Optional[str] = None):
380
  if not config.WEATHER_API_KEY:
 
361
  raise HTTPException(status_code=502, detail=f"WeatherAPI request failed: {e}")
362
 
363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  @app.get("/weather/ip")
365
  def weather_ip(ip: Optional[str] = None):
366
  if not config.WEATHER_API_KEY: