mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-08 11:56:59 +00:00
Avoid model endpoint probes on boot
This commit is contained in:
@@ -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,7 +1438,10 @@ 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
|
||||
# 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
|
||||
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user