feat: natural language date shortcuts for litellm_cost()

Adds _resolve_date() helper that converts natural language shortcuts
into YYYY-MM-DD before calling the LiteLLM API.

Supported shortcuts:
- today, yesterday, tomorrow
- N days ago (e.g. "two days ago")
- monday-sunday (most recent occurrence)
- last monday-last sunday
- this week, last week
- this month, last month

Falls back to passthrough for already-formatted YYYY-MM-DD strings.

Updated README with new parameter documentation.
This commit is contained in:
rin.kagamine committed 2026-06-13 16:42:39 -04:00
1 parent 67f79cfabe
commit 0fd8fcb742
2 files changed
+79 -5

No files matched your search

+2 -2
View File
@@ -11,8 +11,8 @@ Check LiteLLM proxy health and authentication status. Returns which models are h
Get LiteLLM cost breakdown for a date range. Returns per-model and per-day spend, token counts, cache hit rate, and request stats.
**Parameters:**
- `start_date` (str, required): Start date in YYYY-MM-DD format
- `end_date` (str, required): End date in YYYY-MM-DD format
- `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.
### `litellm_history`