fix: model naming for affinity status for llama endpoints

This commit is contained in:
Alpha Nerd 2026-05-13 14:35:45 +02:00
parent aa7ec6354a
commit ad0be90a70
Signed by: alpha-nerd
SSH key fingerprint: SHA256:QkkAgVoYi9TQ0UKPkiKSfnerZy2h4qhi3SVPXJmBN+M

View file

@ -3121,15 +3121,19 @@ async def affinity_stats(request: Request):
now = time.monotonic() now = time.monotonic()
entries: list[dict] = [] entries: list[dict] = []
llama_eps = set(config.llama_server_endpoints)
async with _affinity_lock: async with _affinity_lock:
for fp, (ep, mdl, expires_at) in list(_affinity_map.items()): for fp, (ep, mdl, expires_at) in list(_affinity_map.items()):
remaining = expires_at - now remaining = expires_at - now
if remaining <= 0: if remaining <= 0:
_affinity_map.pop(fp, None) _affinity_map.pop(fp, None)
continue continue
# Mirror the normalisation used by /api/ps_details so the dashboard
# can join affinity entries to PS rows by (endpoint, model).
display_model = _normalize_llama_model_name(mdl) if ep in llama_eps else mdl
entries.append({ entries.append({
"endpoint": ep, "endpoint": ep,
"model": mdl, "model": display_model,
"remaining": round(remaining, 2), "remaining": round(remaining, 2),
}) })
return { return {