fix: hide_zero_spend now filters models with sub-$0.001 spend

Previously filtered only exact $0.00, which left models with tiny
fractional spend (e.g. $0.0001) visible. Now hides anything below
$0.001 threshold — statistically insignificant noise.

- Changed comparison from == 0 to < 0.001
- Updated docstring and summary text
- Updated README parameter description
This commit is contained in:
rin.kagamine committed 2026-06-13 16:25:15 -04:00
1 parent 6adcd79c1a
commit 67f79cfabe
2 files changed
+4 -4

No files matched your search

+3 -3
View File
@@ -125,7 +125,7 @@ class Tools:
Get LiteLLM cost breakdown for a date range.
:param start_date: Start date in YYYY-MM-DD format (e.g. "2026-06-01")
:param end_date: End date in YYYY-MM-DD format (e.g. "2026-06-04")
:param hide_zero_spend: Hide models with $0.00 spend (default False). Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but zero cost.
:param hide_zero_spend: Hide models with sub-$0.001 spend (default False). Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but negligible cost.
Returns formatted cost report with per-model and per-day breakdowns, token counts, cache hit rate, and request stats.
"""
if not self.valves.litellm_master_key:
@@ -210,7 +210,7 @@ class Tools:
hidden_count = 0
for model_name in sorted(model_totals, key=lambda k: model_totals[k]["spend"], reverse=True):
mt = model_totals[model_name]
if hide_zero_spend and mt["spend"] == 0:
if hide_zero_spend and mt["spend"] < 0.001:
hidden_count += 1
continue
# Strip common provider prefixes for readability
@@ -244,7 +244,7 @@ class Tools:
lines.append(f' {"Model":25s} {"Spend":>7s} | {"Requests":>14s} | {"Tokens":>10s}')
lines.extend(model_lines)
if hidden_count > 0:
lines.append(f" ... ({hidden_count} model(s) with $0.00 spend hidden)")
lines.append(f" ... ({hidden_count} model(s) with sub-$0.001 spend hidden)")
lines.append("")
lines.append("By Date:")
lines.extend(date_lines)