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:
1 parent
6adcd79c1a
commit
67f79cfabe
2 files changed
+4
-4
No files matched your search
@@ -13,7 +13,7 @@ Get LiteLLM cost breakdown for a date range. Returns per-model and per-day spend
|
|||||||
**Parameters:**
|
**Parameters:**
|
||||||
- `start_date` (str, required): Start date in YYYY-MM-DD format
|
- `start_date` (str, required): Start date in YYYY-MM-DD format
|
||||||
- `end_date` (str, required): End date in YYYY-MM-DD format
|
- `end_date` (str, required): End date in YYYY-MM-DD format
|
||||||
- `hide_zero_spend` (bool, default false): Hide models with $0.00 spend. Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but zero cost.
|
- `hide_zero_spend` (bool, default false): Hide models with sub-$0.001 spend. Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but negligible cost.
|
||||||
|
|
||||||
### `litellm_history`
|
### `litellm_history`
|
||||||
Get recent LiteLLM request history. Returns the most recent N requests with model, call type, status, duration, token counts, cache hit %, and per-request cost. Useful for understanding which models are being called and how much individual requests cost.
|
Get recent LiteLLM request history. Returns the most recent N requests with model, call type, status, duration, token counts, cache hit %, and per-request cost. Useful for understanding which models are being called and how much individual requests cost.
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class Tools:
|
|||||||
Get LiteLLM cost breakdown for a date range.
|
Get LiteLLM cost breakdown for a date range.
|
||||||
:param start_date: Start date in YYYY-MM-DD format (e.g. "2026-06-01")
|
: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 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.
|
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:
|
if not self.valves.litellm_master_key:
|
||||||
@@ -210,7 +210,7 @@ class Tools:
|
|||||||
hidden_count = 0
|
hidden_count = 0
|
||||||
for model_name in sorted(model_totals, key=lambda k: model_totals[k]["spend"], reverse=True):
|
for model_name in sorted(model_totals, key=lambda k: model_totals[k]["spend"], reverse=True):
|
||||||
mt = model_totals[model_name]
|
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
|
hidden_count += 1
|
||||||
continue
|
continue
|
||||||
# Strip common provider prefixes for readability
|
# Strip common provider prefixes for readability
|
||||||
@@ -244,7 +244,7 @@ class Tools:
|
|||||||
lines.append(f' {"Model":25s} {"Spend":>7s} | {"Requests":>14s} | {"Tokens":>10s}')
|
lines.append(f' {"Model":25s} {"Spend":>7s} | {"Requests":>14s} | {"Tokens":>10s}')
|
||||||
lines.extend(model_lines)
|
lines.extend(model_lines)
|
||||||
if hidden_count > 0:
|
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("")
|
||||||
lines.append("By Date:")
|
lines.append("By Date:")
|
||||||
lines.extend(date_lines)
|
lines.extend(date_lines)
|
||||||
|
|||||||
Reference in new issue
Block a user