fix: avoid worker fetch noise when server is offline
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user