fix: avoid worker fetch noise when server is offline

This commit is contained in:
Luca Sacchi Ricciardi
2026-04-25 16:30:46 +02:00
parent 1c76515d8c
commit 6739b84b9a
3 changed files with 23 additions and 6 deletions
+2
View File
@@ -126,6 +126,8 @@ async def get_models(host: Optional[str] = Query(default=None)):
status_code=502,
detail="Impossible connettersi a Ollama"
)
except HTTPException:
raise
except Exception as e:
logger.error(f"Error fetching models: {e}")
raise HTTPException(
+7 -4
View File
@@ -49,7 +49,9 @@ async function fetchModels() {
try {
const response = await fetch(buildApiUrl(`${API_BASE}/models`));
if (!response.ok) throw new Error("Failed to load models");
if (!response.ok) {
return null;
}
const data = await response.json();
const models = data.models || [];
@@ -108,7 +110,7 @@ async function fetchRunningModels() {
try {
const response = await fetch(buildApiUrl(`${API_BASE}/models/running`));
if (!response.ok) {
throw new Error("Failed to load running models");
return null;
}
const data = await response.json();
@@ -137,8 +139,9 @@ async function syncData() {
}
const health = await fetchHealth();
const modelsData = await fetchModels();
const runningData = await fetchRunningModels();
const isOnline = health?.ollama_status === "online";
const modelsData = isOnline ? await fetchModels() : null;
const runningData = isOnline ? await fetchRunningModels() : null;
if (modelsData && modelsData.models.length > 0) {
modelsData.showByModel = await fetchAllModelsShow(modelsData.models);