From a48f11c6549c3e5efff7d35f10d0eb836730244a Mon Sep 17 00:00:00 2001 From: inference-bot Date: Sat, 26 Sep 2026 15:33:24 -0600 Subject: [PATCH] Prefer model_group alias in model-usage aggregation --- app/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 9661035..1a22700 100644 --- a/app/main.py +++ b/app/main.py @@ -1345,7 +1345,12 @@ async def admin_model_usage(request: Request): if isinstance(rows, dict): rows = rows.get("data", rows.get("logs", [])) for row in rows if isinstance(rows, list) else []: - model = row.get("model") or row.get("model_group") or "unknown" + # Prefer model_group: it carries our provider/model alias (e.g. + # greenpt/green-r, publicai/apertus-v1.5-8b) when present; the + # raw `model` field holds messy upstream/internal names. Older + # rows predating the alias convention have model_group empty, + # so fall back to `model` for those. + model = row.get("model_group") or row.get("model") or "unknown" m = models.setdefault(model, {"spend": 0.0, "tokens": 0, "requests": 0}) m["spend"] += float(row.get("spend") or 0.0) m["tokens"] += int(row.get("total_tokens") or 0)