diff --git a/litellm/proxy/guardrails/guardrail_hooks/tealtiger/engine.py b/litellm/proxy/guardrails/guardrail_hooks/tealtiger/engine.py index 082af5661ac..fec4fb360cc 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/tealtiger/engine.py +++ b/litellm/proxy/guardrails/guardrail_hooks/tealtiger/engine.py @@ -8,9 +8,8 @@ from __future__ import annotations import threading import uuid from dataclasses import dataclass, field -from datetime import date +from datetime import datetime from enum import Enum -from typing import Optional from .patterns import default_patterns @@ -31,7 +30,7 @@ class Decision: action: str reason_code: str correlation_id: str - redacted_text: Optional[str] = None + redacted_text: str | None = None details: dict = field(default_factory=dict) def to_receipt(self) -> dict: @@ -109,14 +108,14 @@ class TealEngine: limit = self._cost_policy.get("daily_limit_usd") if limit is None: return False, 0.0, 0.0 - today = date.today().isoformat() + today = datetime.now().astimezone().date().isoformat() with self._lock: spent = self._spend_by_day.get(today, 0.0) return spent >= limit, spent, limit def track_cost(self, tokens: int, cost_per_1k_tokens: float = 0.002) -> float: cost = (tokens / 1000.0) * cost_per_1k_tokens - today = date.today().isoformat() + today = datetime.now().astimezone().date().isoformat() with self._lock: self._spend_by_day[today] = self._spend_by_day.get(today, 0.0) + cost return cost diff --git a/litellm/proxy/guardrails/guardrail_hooks/tealtiger/tealtiger.py b/litellm/proxy/guardrails/guardrail_hooks/tealtiger/tealtiger.py index 6c8dc0e61f0..2edbd6820a7 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/tealtiger/tealtiger.py +++ b/litellm/proxy/guardrails/guardrail_hooks/tealtiger/tealtiger.py @@ -10,7 +10,7 @@ implementation of the same interface. No network calls, no LLM calls, no external API keys required. """ -from typing import TYPE_CHECKING, Final, List, Literal, Optional +from typing import TYPE_CHECKING, Final, Literal, Optional from litellm.integrations.custom_guardrail import ( CustomGuardrail, @@ -33,7 +33,7 @@ DEFAULT_POLICIES = [ class TealTigerGuardrail(CustomGuardrail): def __init__( self, - policies: Optional[list] = None, + policies: list | None = None, policy_mode: str = "ENFORCE", **kwargs, ): @@ -68,7 +68,7 @@ class TealTigerGuardrail(CustomGuardrail): if over_budget: raise ValueError(f"TealTiger: blocked — DAILY_BUDGET_EXCEEDED (${spent:.2f} / ${limit:.2f})") - checked_texts: List[str] = [] + checked_texts: list[str] = [] for text in inputs.get("texts") or []: decision = self.engine.evaluate_text(text)