mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-15 12:58:04 +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}
|
return {"hosts": [], "items": items}
|
||||||
|
|
||||||
@router.get("/models")
|
@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 +
|
"""Get available models — per-user (caller sees only their endpoints +
|
||||||
legacy/shared null-owner rows). Cached per-user for 30s."""
|
legacy/shared null-owner rows). Cached per-user for 30s."""
|
||||||
# Require auth; "" is the unconfigured single-user mode, treated as
|
# Require auth; "" is the unconfigured single-user mode, treated as
|
||||||
@@ -1438,8 +1438,11 @@ def setup_model_routes(model_discovery):
|
|||||||
return cache_entry["data"]
|
return cache_entry["data"]
|
||||||
result = _fetch_models(owner=owner, is_admin=_is_admin)
|
result = _fetch_models(owner=owner, is_admin=_is_admin)
|
||||||
_models_cache[_cache_key] = {"data": result, "time": now}
|
_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.
|
||||||
_refresh_caches_bg(force=refresh)
|
# 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
|
return result
|
||||||
|
|
||||||
# Brief cache for local-probe results so picker-open doesn't hammer
|
# Brief cache for local-probe results so picker-open doesn't hammer
|
||||||
|
|||||||
+1
-1
@@ -3968,7 +3968,7 @@ function startOdysseusApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Non-critical: load in parallel, resolve silently
|
// Non-critical: load in parallel, resolve silently
|
||||||
modelsModule.refreshModels(true).then(() => {
|
modelsModule.refreshModels(false).then(() => {
|
||||||
const modelsBox = document.getElementById('models');
|
const modelsBox = document.getElementById('models');
|
||||||
const hasModels = modelsBox && modelsBox.querySelector('.models-row');
|
const hasModels = modelsBox && modelsBox.querySelector('.models-row');
|
||||||
if (!hasModels) {
|
if (!hasModels) {
|
||||||
|
|||||||
+1
-1
@@ -184,7 +184,7 @@ export async function refreshModels(force = false) {
|
|||||||
// back — newly-served endpoints don't appear until the cache
|
// back — newly-served endpoints don't appear until the cache
|
||||||
// ages out. (Bug repro: serve a model, picker is empty for ~30s
|
// ages out. (Bug repro: serve a model, picker is empty for ~30s
|
||||||
// even though the endpoint is in the DB and online.)
|
// 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' })
|
_fetchInflight = fetch(_url, { credentials: 'same-origin' })
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user