diff --git a/litellm/integrations/slack_alerting.py b/litellm/integrations/slack_alerting.py index b42f6d799b3..bf0f5c07d20 100644 --- a/litellm/integrations/slack_alerting.py +++ b/litellm/integrations/slack_alerting.py @@ -71,7 +71,7 @@ class SlackAlerting(CustomLogger): # Class variables or attributes def __init__( self, - internal_usage_cache: DualCache, + internal_usage_cache: Optional[DualCache] = None, alerting_threshold: float = 300, alerting: Optional[List] = [], alert_types: Optional[ @@ -101,7 +101,7 @@ class SlackAlerting(CustomLogger): self.alerting_threshold = alerting_threshold self.alerting = alerting self.alert_types = alert_types - self.internal_usage_cache = internal_usage_cache + self.internal_usage_cache = internal_usage_cache or DualCache() self.async_http_handler = AsyncHTTPHandler() self.alert_to_webhook_url = alert_to_webhook_url self.is_running = False diff --git a/litellm/tests/test_alerting.py b/litellm/tests/test_alerting.py index dd77a0d3135..c4b6157bcf4 100644 --- a/litellm/tests/test_alerting.py +++ b/litellm/tests/test_alerting.py @@ -98,7 +98,10 @@ def mock_env(monkeypatch): # Test the __init__ method def test_init(): slack_alerting = SlackAlerting( - alerting_threshold=32, alerting=["slack"], alert_types=["llm_exceptions"] + alerting_threshold=32, + alerting=["slack"], + alert_types=["llm_exceptions"], + internal_usage_cache=DualCache(), ) assert slack_alerting.alerting_threshold == 32 assert slack_alerting.alerting == ["slack"]