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:
1 parent
7ab17e03d7
commit
091d44ab87
3 files changed
+10
-8
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user