fix: verify and highlight resident Ollama models
This commit is contained in:
+20
-1
@@ -1398,7 +1398,26 @@ def models_load(body: ModelsRequest) -> dict[str, Any]:
|
||||
results.append({"name": name, "ok": True, "result": _load_model(name)})
|
||||
except Exception as exc:
|
||||
results.append({"name": name, "ok": False, "error": str(exc)})
|
||||
return {"ok": all(item["ok"] for item in results), "results": results, "runtime": _runtime_snapshot(), "keep_alive": "permanent"}
|
||||
resident_rows = _local_ps()
|
||||
resident_names = {str(row.get("name") or row.get("model")) for row in resident_rows}
|
||||
for item in results:
|
||||
item["resident"] = item["name"] in resident_names
|
||||
not_resident = [name for name in names if name not in resident_names]
|
||||
runtime = _runtime_snapshot()
|
||||
return {
|
||||
"ok": bool(results) and not not_resident and all(item["ok"] for item in results),
|
||||
"requested": names,
|
||||
"resident": sorted(resident_names),
|
||||
"not_resident": not_resident,
|
||||
"results": results,
|
||||
"runtime": runtime,
|
||||
"keep_alive": "permanent",
|
||||
"message": (
|
||||
"All selected models are resident."
|
||||
if not not_resident
|
||||
else "Ollama did not keep every selected model resident; see not_resident."
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@router.post("/models/unload")
|
||||
|
||||
Reference in New Issue
Block a user