feat: two-level zero-spend filtering with valve default

Adds default_hide_zero_spend valve (default True) that controls whether
models with sub-bash.001 spend are hidden by default. The per-call
hide_zero_spend parameter can explicitly override:

- hide_zero_spend=True → ALWAYS hide (explicit override)
- hide_zero_spend=False → use valve default (default_hide_zero_spend)

This defensive design prevents SLMs from accidentally exposing zero-spend
models unless the human has explicitly set default_hide_zero_spend=False.

- Added default_hide_zero_spend valve to Valves class
- Updated litellm_cost() with two-level logic
- Updated README and ARCHITECTURE.md with two-level design docs
- Reverted parameter name back to hide_zero_spend
This commit is contained in:
rin.kagamine committed 2026-06-13 16:53:37 -04:00
1 parent 091d44ab87
commit 097a29eaee
3 files changed
+36 -24

No files matched your search

+3 -2
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
- `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.
- `hide_zero_spend` (bool, default false): When True, force-hide models with sub-$0.001 spend. When False, use the valve-configured default (see `default_hide_zero_spend` below). This two-level design lets the human set a default via valves while allowing the SLM to explicitly override on a per-call basis.
### `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.
@@ -31,6 +31,7 @@ Get recent LiteLLM request history. Returns the most recent N requests with mode
|-------|---------|---------|
| `litellm_url` | `http://localhost:4000` | LiteLLM proxy base URL |
| `litellm_master_key` | (empty) | LiteLLM master API key (password field) |
| `default_hide_zero_spend` | `True` | Default behavior for zero-spend model filtering. When True, models with sub-$0.001 spend are hidden by default. The per-call `hide_zero_spend` parameter can override this. |
Both valves are passed at runtime — no hardcoded keys. The tool is portable to any LiteLLM proxy instance.
@@ -63,7 +64,7 @@ Both valves are passed at runtime — no hardcoded keys. The tool is portable to
### 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:** `hide_zero_spend` parameter for `litellm_cost()` — default True hides sub-$0.001 models with summary line; per-call parameter can override
- **fix:** Cost report header shows resolved YYYY-MM-DD dates instead of raw shortcuts
### v1.1.0 (2026-06-13)