feat(health): improve provider grouping and wildcard resolution for ollama-cloud

This commit is contained in:
vai committed 2026-06-27 10:16:48 +00:00
1 parent 9490a66451
commit b84cf34e88
2 files changed
+31 -8

No files matched your search

+24 -8
View File
@@ -179,27 +179,40 @@ class Tools:
groups = {}
for ep in healthy + unhealthy:
m_raw = ep.get("model", "unknown")
# Wildcard Linkage: Cross-reference with model_info_cache
m_display = self._compact_name(m_raw, 32)
# Wildcard Linkage
found_alias = False
for info in self._model_info_cache:
# If this model name is the 'health_check_model' for a wildcard
if info.get("model_info", {}).get("health_check_model") == m_raw:
m_display = f"{self._compact_name(info.get('model_name'), 25)} (via {m_display.split('/')[-1]})"
alias = info.get("model_name", "unknown")
m_display = f"{self._compact_name(alias, 28)} (via {m_display})"
found_alias = True
break
if not found_alias and "*" in m_raw:
meta = ep.get("litellm_metadata", {}) or {}
probe = meta.get("health_check_model", "generic")
m_display = f"{m_display} (via {probe.split('/')[-1]})"
provider = m_raw.split("/")[0] if "/" in m_raw else "other"
# Provider Determination
provider = "other"
if "ollama" in ep.get("api_base", "").lower() or "ollama" in m_raw.lower():
provider = "ollama"
elif "/" in m_raw:
provider = m_raw.split("/")[0]
if provider not in groups: groups[provider] = {"ok": [], "fail": []}
icon = "✅" if ep in healthy else "❌"
info_line = f" {icon} {m_display:35s} | rpm: {ep.get('rpm','?'):>3}"
info_line = f" {icon} {m_display:40s} | rpm: {ep.get('rpm','?'):>3}"
if ep in healthy: groups[provider]["ok"].append(info_line)
else: groups[provider]["fail"].append(info_line)
lines.append(f"\nFleet Status: {len(healthy)} healthy, {len(unhealthy)} unhealthy")
for prov, stats in groups.items():
for prov in sorted(groups.keys()):
lines.append(f"\n--- {prov.upper()} ---")
lines.extend(stats["ok"] + stats["fail"])
lines.extend(groups[prov]["ok"] + groups[prov]["fail"])
else: lines.append(f"\n❌ Fleet Check Failed: Status {resp.status_code}")
except Exception as e: lines.append(f"\n❌ Fleet Check Failed: {str(e)}")
@@ -309,6 +322,9 @@ class Tools:
cached = entry.get("cache_read_input_tokens", 0) or 0
cache_s = f" 💾{int(cached/p_tok*100)}%" if p_tok and cached else ""
p_f = f"{p_tok/1000:.1f}k" if p_tok >= 1000 else str(p_tok)
c_f = f"{c_tok/1000:.1f}k" if c_tok >= 1000 else str(c_tok)
audit = self._audit_cost(entry.get("model"), p_tok, cached, c_tok, spend, reasoning=thought, has_search=has_search)
line = f" {i:2d}. {ts} | {model:28s} | {status} | {dur_s:>6s}{slow} | ${spend:.4f}{audit:18s} | {self._format_tokens(p_tok):>6s}→{self._format_tokens(c_tok):<6s}{thought_s}{cache_s}{search_s}"