refactor: invert hide_zero_spend → show_zero_spend, default False

Changes the API from opt-in hiding (hide_zero_spend) to opt-in showing
(show_zero_spend). Default behavior now hides sub-bash.001 models and
shows the summary line — cleaner for the common case where free-tier
models dominate the breakdown.

- Renamed parameter: hide_zero_spend → show_zero_spend
- Inverted logic: default False means hide by default
- Updated docstrings, README, ARCHITECTURE.md
This commit is contained in:
rin.kagamine committed 2026-06-13 16:48:13 -04:00
1 parent 7ab17e03d7
commit 091d44ab87
3 files changed
+10 -8

No files matched your search

+6 -4
View File
@@ -93,7 +93,7 @@ Healthy: 8 | Unhealthy: 0
**LiteLLM Endpoint:** `GET {litellm_url}/user/daily/activity`
**Auth:** `Authorization: Bearer {litellm_master_key}`
**Params:** `start_date` (YYYY-MM-DD or natural language shortcut), `end_date` (YYYY-MM-DD or natural language shortcut), `hide_zero_spend` (bool, default False)
**Params:** `start_date` (YYYY-MM-DD or natural language shortcut), `end_date` (YYYY-MM-DD or natural language shortcut), `show_zero_spend` (bool, default False)
### Natural Language Date Resolution
@@ -109,9 +109,11 @@ The `_resolve_date()` helper converts natural language shortcuts to YYYY-MM-DD b
Already-formatted YYYY-MM-DD strings pass through unchanged. Unrecognized strings are passed to the API, which will reject them with a clear error.
### hide_zero_spend Parameter
### show_zero_spend Parameter
When `hide_zero_spend=True`, models with sub-$0.001 spend are filtered from the per-model breakdown. This is useful when free-tier or subscription models (e.g., Ollama Cloud) dominate the report with high token counts but negligible cost. Hidden models are summarized as `... (N model(s) with sub-$0.001 spend hidden)`.
When `show_zero_spend=False` (the default), models with sub-$0.001 spend are hidden from the per-model breakdown and summarized as `... (N model(s) with sub-$0.001 spend hidden)`. This is the recommended default because free-tier or subscription models (e.g., Ollama Cloud) often dominate the report with high token counts but negligible cost, drowning out the models that actually cost money.
Set `show_zero_spend=True` to see all models, including those with zero or near-zero spend.
### Response Processing
@@ -256,7 +258,7 @@ These are documented but not in scope for v1. The two-function design is the rig
### v1.2.0 (2026-06-13)
- **feat:** Natural language date shortcuts for `litellm_cost()` — `today`, `yesterday`, `monday`, `last week`, etc.
- **feat:** `hide_zero_spend` parameter for `litellm_cost()` — filters sub-$0.001 models from breakdown
- **feat:** `show_zero_spend` parameter for `litellm_cost()` — default False hides sub-$0.001 models with summary line
- **fix:** Cost report header shows resolved YYYY-MM-DD dates instead of raw shortcuts
### v1.1.0 (2026-06-13)
+1 -1
View File
@@ -13,7 +13,7 @@ Get LiteLLM cost breakdown for a date range. Returns per-model and per-day spend
**Parameters:**
- `start_date` (str, required): Start date — YYYY-MM-DD or natural language shortcut (e.g. "2026-06-01", "today", "yesterday", "monday", "last monday", "two days ago", "this week", "last month")
- `end_date` (str, required): End date — YYYY-MM-DD or natural language shortcut
- `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.
- `show_zero_spend` (bool, default false): Show models with sub-$0.001 spend. When false, these models are hidden and summarized as "... (N model(s) with sub-$0.001 spend hidden)". Useful when free-tier or subscription models (e.g. Ollama Cloud) dominate the breakdown with high token counts but negligible cost.
### `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.
+3 -3
View File
@@ -190,13 +190,13 @@ class Tools:
self,
start_date: str,
end_date: str,
hide_zero_spend: bool = False,
show_zero_spend: bool = False,
) -> str:
"""
Get LiteLLM cost breakdown for a date range.
:param start_date: Start date — YYYY-MM-DD or natural language shortcut (e.g. "2026-06-01", "today", "yesterday", "monday", "last monday", "two days ago", "this week", "last month")
:param end_date: End date — YYYY-MM-DD or natural language shortcut
: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.
:param show_zero_spend: Show models with sub-$0.001 spend (default False). When False, these models are hidden and summarized as "... (N model(s) with sub-$0.001 spend hidden)". 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:
@@ -284,7 +284,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.001:
if not show_zero_spend and mt["spend"] < 0.001:
hidden_count += 1
continue
# Strip common provider prefixes for readability