feat: persist summarizer model in app_settings

This commit is contained in:
Sirius DevOps 2026-08-27 23:07:01 -04:00
commit 1616413e65
4 changed files with 451 additions and 1 deletions

View file

@ -40,6 +40,7 @@ from schemas import (
NewsSummaryOut, NewsTickerItemOut,
FeedSourceCreate, FeedSourceOut,
KeyOut, KeyValueIn,
NewsModelsOut, SettingsIn, SettingsOut,
SearchResult, SentimentSummary, SourceType,
SearchQuery, TimelinePoint, VesselBboxUpdate,
GeofenceCreate, GeofenceUpdate,
@ -48,6 +49,7 @@ from ingestor import ingest_event, fetch_and_process
from sources import ingest_rss_feed, ingest_gdelt, ingest_earthquakes, ingest_social_signals
from fire_sources import ingest_fires
from keystore import KeyFormatError, delete_key, list_keys, set_key
from settings_store import SettingsError, get_app_settings, list_models, set_summary_model
from live_layers import (
fetch_aircraft, fetch_fire_incidents, fetch_fire_perimeters,
fetch_radar_meta, fetch_storms, fetch_trains, fetch_vessels,
@ -634,6 +636,21 @@ async def remove_api_key(name: str):
return {"ok": True}
@app.get("/api/settings", response_model=SettingsOut)
async def get_settings():
"""Summarizer model + read-only Nous base URL."""
return await get_app_settings()
@app.put("/api/settings", response_model=SettingsOut)
async def put_settings(payload: SettingsIn):
"""Persist SUMMARY_MODEL. ``nous_base_url`` is ignored even if sent."""
try:
return await set_summary_model(payload.summary_model)
except SettingsError as exc:
raise HTTPException(status_code=422, detail=str(exc))
# ── Ingestion Triggers ───────────────────────────────────────────────────
@app.post("/api/ingest/rss")
@ -1230,6 +1247,12 @@ async def list_news_map(
]
@app.get("/api/news/models", response_model=NewsModelsOut)
async def list_news_models():
"""Nous model catalog for the summarizer selector. Never 502s."""
return await list_models()
# ── Frontend ──────────────────────────────────────────────────────────────
@app.get("/", response_class=HTMLResponse)