fix: add timezone_offset valve for local date resolution

This commit is contained in:
rin.kagamine committed 2026-06-14 13:51:45 -04:00
1 parent 097a29eaee
commit 1a6e06c2bd
1 file changed
+7 -2
+7 -2
View File
@@ -5,7 +5,7 @@ author_url: https://rin.captcouch.xyz
description: Check LiteLLM proxy health + auth status and get cost breakdowns with configurable timerange. Two functions, that's it.
required_open_webui_version: 0.4.0
requirements: requests
version: 1.2.0
version: 1.2.1
licence: MIT
"""
@@ -34,6 +34,10 @@ class Tools:
default=True,
description="Default behavior for zero-spend model filtering. When True, models with sub-$0.001 spend are hidden by default and summarized. The per-call hide_zero_spend parameter can override this.",
)
timezone_offset: int = Field(
default=0,
description="Timezone offset from UTC in hours (e.g. -4 for EDT, -5 for EST). Used for natural language date resolution (today, yesterday).",
)
def _headers(self) -> dict:
"""Build auth headers from valves."""
@@ -54,7 +58,8 @@ class Tools:
Falls back to passthrough if already YYYY-MM-DD or unrecognized.
"""
date_str = date_str.strip().lower()
today = datetime.utcnow().date()
# Apply timezone offset to UTC now to get "local" today
today = (datetime.utcnow() + timedelta(hours=self.valves.timezone_offset)).date()
# Direct shortcuts
if date_str == "today":