mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
fix(mavvrik): fix dry_run TypeError on NULL spend and missing column guard
Bug 1: float(df["spend"].sum()) raises TypeError when all spend values are NULL — polars .sum() returns None for an all-null series. Fix: float(df["spend"].sum() or 0.0) Bug 2: df["completion_tokens"].sum() accessed without checking the column exists — only "prompt_tokens" was guarded. Raises ColumnNotFoundError if schema omits completion_tokens. Fix: guard both columns together before summing. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2f6742a700
commit
4962c1d62a
1 changed files with 2 additions and 2 deletions
|
|
@ -387,10 +387,10 @@ class Service:
|
|||
},
|
||||
}
|
||||
|
||||
total_cost = float(df["spend"].sum()) if "spend" in df.columns else 0.0
|
||||
total_cost = float(df["spend"].sum() or 0.0) if "spend" in df.columns else 0.0
|
||||
total_tokens = (
|
||||
int((df["prompt_tokens"].sum() or 0) + (df["completion_tokens"].sum() or 0))
|
||||
if "prompt_tokens" in df.columns
|
||||
if "prompt_tokens" in df.columns and "completion_tokens" in df.columns
|
||||
else 0
|
||||
)
|
||||
unique_models = df["model"].n_unique() if "model" in df.columns else 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue