feat: add cv benchmark workflow and admin visibility

This commit is contained in:
2026-04-01 12:25:45 +02:00
parent 0551a525a8
commit 0d65835857
16 changed files with 832 additions and 95 deletions
+27 -5
View File
@@ -63,6 +63,12 @@ def _key(text: str, max_length: int, min_length: int, top_skills: int) -> str:
return f"{h}:{max_length}:{min_length}:{top_skills}"
def _ollama_json(path: str):
req = urllib_request.Request(f"{OLLAMA_BASE_URL}{path}", method="GET")
with urllib_request.urlopen(req, timeout=5) as response:
return json.loads(response.read().decode("utf-8"))
def _ollama_status():
configured = bool(OLLAMA_MODEL)
if not configured:
@@ -71,27 +77,43 @@ def _ollama_status():
"ollama_reachable": False,
"ollama_model": None,
"ollama_model_available": False,
"ollama_version": None,
"ollama_installed_models": [],
"ollama_loaded_models": [],
"ollama_loaded_count": 0,
}
req = urllib_request.Request(f"{OLLAMA_BASE_URL}/api/tags", method="GET")
try:
with urllib_request.urlopen(req, timeout=5) as response:
body = json.loads(response.read().decode("utf-8"))
tags_body = _ollama_json("/api/tags")
version_body = _ollama_json("/api/version")
try:
ps_body = _ollama_json("/api/ps")
except Exception:
ps_body = {"models": []}
except Exception:
return {
"ollama_configured": True,
"ollama_reachable": False,
"ollama_model": OLLAMA_MODEL,
"ollama_model_available": False,
"ollama_version": None,
"ollama_installed_models": [],
"ollama_loaded_models": [],
"ollama_loaded_count": 0,
}
models = body.get("models") or []
names = {item.get("name") for item in models if isinstance(item, dict)}
models = tags_body.get("models") or []
names = sorted({item.get("name") for item in models if isinstance(item, dict) and item.get("name")})
loaded_models = sorted({item.get("name") for item in (ps_body.get("models") or []) if isinstance(item, dict) and item.get("name")})
return {
"ollama_configured": True,
"ollama_reachable": True,
"ollama_model": OLLAMA_MODEL,
"ollama_model_available": OLLAMA_MODEL in names,
"ollama_version": version_body.get("version"),
"ollama_installed_models": names,
"ollama_loaded_models": loaded_models,
"ollama_loaded_count": len(loaded_models),
}