From e8988b9c4e5c5208edaf94707f58eeb77d0a301a Mon Sep 17 00:00:00 2001 From: VAI Date: Sat, 27 Jun 2026 10:21:13 +0000 Subject: [PATCH] feat(health): implement dynamic model fleet expansion for wildcard endpoints --- litellm_dashboard.py | 61 +++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/litellm_dashboard.py b/litellm_dashboard.py index 725a606..68ab90a 100644 --- a/litellm_dashboard.py +++ b/litellm_dashboard.py @@ -2,10 +2,10 @@ title: LiteLLM Dashboard author: Kagamine Rin & VAI author_url: https://rin.captcouch.xyz -description: Professional LiteLLM observability — Grouped health, wildcard resolution, and Billion-scale token tracking. +description: Professional LiteLLM observability — Fleet expansion, proactive budget monitoring, and Billion-scale token tracking. required_open_webui_version: 0.4.0 requirements: requests -version: 1.6.2 +version: 1.6.4 licence: MIT """ @@ -141,7 +141,7 @@ class Tools: return date_str def litellm_health(self) -> str: - """Check LiteLLM proxy health, proactive budget, and grouped model readiness.""" + """Check LiteLLM proxy health, proactive budget, and grouped model fleet expansion.""" self._fetch_live_data() lines = [f"LiteLLM Health & Budget — {self._base_url()}"] lines.append("=" * 70) @@ -167,7 +167,7 @@ class Tools: lines.append(f"✅ Proxy: {d.get('status')} | DB: {d.get('db')} | v{d.get('litellm_version')}") except Exception: pass - # 3. Model Fleet (Grouped by Provider + Wildcard Linkage) + # 3. Model Fleet (Grouped by Provider + Wildcard Expansion) try: url = f"{self._base_url()}/health" resp = requests.get(url, headers=self._headers(), timeout=15) @@ -179,35 +179,56 @@ class Tools: groups = {} for ep in healthy + unhealthy: m_raw = ep.get("model", "unknown") - m_display = self._compact_name(m_raw, 32) + api_base = ep.get("api_base", "") - # Wildcard Linkage - found_alias = False + # Wildcard & Fleet Discovery + m_display = self._compact_name(m_raw, 32) + fleet_members = [] + + # Search for wildcard/alias labels + target_id = None for info in self._model_info_cache: - if info.get("model_info", {}).get("health_check_model") == m_raw: - alias = info.get("model_name", "unknown") - m_display = f"{self._compact_name(alias, 28)} (via {m_display})" - found_alias = True + m_info = info.get("model_info", {}) + if m_info.get("health_check_model") == m_raw: + m_display = info.get("model_name", m_raw) + target_id = m_info.get("id") 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]})" + if not target_id: # Direct match fallback + for info in self._model_info_cache: + if info.get("model_name") == m_raw: + target_id = info.get("model_info", {}).get("id") + break + # Populate members sharing this ID (The Fleet) + if target_id: + for info in self._model_info_cache: + if info.get("model_info", {}).get("id") == target_id and info.get("model_name") != m_display: + name_part = info.get("model_name", "").split("/")[-1] + if name_part and name_part != "*": + fleet_members.append(name_part) + + icon = "✅" if ep in healthy else "❌" + # Provider Determination provider = "other" - if "ollama" in ep.get("api_base", "").lower() or "ollama" in m_raw.lower(): + if "ollama" in 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:40s} | rpm: {ep.get('rpm','?'):>3}" - if ep in healthy: groups[provider]["ok"].append(info_line) - else: groups[provider]["fail"].append(info_line) + if fleet_members: + m_display = f"{m_display} ({len(fleet_members)} members)" + fleet_lines = [f" {icon} {m_display:45s} | rpm: {ep.get('rpm','?'):>3}"] + fleet_lines.extend([f" └─ • {m}" for m in sorted(list(set(fleet_members)))]) + info_block = "\n".join(fleet_lines) + else: + info_block = f" {icon} {m_display:45s} | rpm: {ep.get('rpm','?'):>3}" + + if ep in healthy: groups[provider]["ok"].append(info_block) + else: groups[provider]["fail"].append(info_block) lines.append(f"\nFleet Status: {len(healthy)} healthy, {len(unhealthy)} unhealthy") for prov in sorted(groups.keys()):