Prefer model_group alias in model-usage aggregation
This commit is contained in:
1 parent
810b878014
commit
a48f11c654
1 file changed
+6
-1
+6
-1
@@ -1345,7 +1345,12 @@ async def admin_model_usage(request: Request):
|
|||||||
if isinstance(rows, dict):
|
if isinstance(rows, dict):
|
||||||
rows = rows.get("data", rows.get("logs", []))
|
rows = rows.get("data", rows.get("logs", []))
|
||||||
for row in rows if isinstance(rows, list) else []:
|
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 = models.setdefault(model, {"spend": 0.0, "tokens": 0, "requests": 0})
|
||||||
m["spend"] += float(row.get("spend") or 0.0)
|
m["spend"] += float(row.get("spend") or 0.0)
|
||||||
m["tokens"] += int(row.get("total_tokens") or 0)
|
m["tokens"] += int(row.get("total_tokens") or 0)
|
||||||
|
|||||||
Reference in new issue
Block a user