Self-hosted AI workspace.
Python
Avoid model endpoint probes on boot
pewdiepie-archdaemon21998a891f0f
diff --git a/routes/model_routes.py b/routes/model_routes.pyindex c570bcb37..5a0ef6d03 100644--- a/routes/model_routes.py+++ b/routes/model_routes.py@@ -1396,7 +1396,7 @@ def setup_model_routes(model_discovery):return {"hosts": [], "items": items}@router.get("/models")- def api_models(request: Request, refresh: bool = False):+ def api_models(request: Request, refresh: bool = False, background: bool = True):"""Get available models — per-user (caller sees only their endpoints +legacy/shared null-owner rows). Cached per-user for 30s."""# Require auth; "" is the unconfigured single-user mode, treated as@@ -1438,8 +1438,11 @@ def setup_model_routes(model_discovery):return cache_entry["data"]result = _fetch_models(owner=owner, is_admin=_is_admin)_models_cache[_cache_key] = {"data": result, "time": now}- # Kick off background refresh to update caches from live endpoints- _refresh_caches_bg(force=refresh)+ # Kick off background refresh to update caches from live endpoints.+ # Page boot can opt out with background=false so opening Odysseus does+ # not start endpoint probes against slow/offline model servers.+ if background or refresh:+ _refresh_caches_bg(force=refresh)return result# Brief cache for local-probe results so picker-open doesn't hammerdiff --git a/static/app.js b/static/app.jsindex d1a8c9f1a..a61d748b8 100644--- a/static/app.js+++ b/static/app.js@@ -3968,7 +3968,7 @@ function startOdysseusApp() {}// Non-critical: load in parallel, resolve silently- modelsModule.refreshModels(true).then(() => {+ modelsModule.refreshModels(false).then(() => {const modelsBox = document.getElementById('models');const hasModels = modelsBox && modelsBox.querySelector('.models-row');if (!hasModels) {diff --git a/static/js/models.js b/static/js/models.jsindex c66876ce0..8f7b1305e 100644--- a/static/js/models.js+++ b/static/js/models.js@@ -184,7 +184,7 @@ export async function refreshModels(force = false) {// back — newly-served endpoints don't appear until the cache// ages out. (Bug repro: serve a model, picker is empty for ~30s// even though the endpoint is in the DB and online.)- const _url = `${API_BASE}/api/models` + (force ? '?refresh=true' : '');+ const _url = `${API_BASE}/api/models` + (force ? '?refresh=true' : '?background=false');_fetchInflight = fetch(_url, { credentials: 'same-origin' }).then(async (res) => {if (!res.ok) throw new Error(`HTTP ${res.status}`);