The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(alerting): clarify budget threshold messages
Gaurav Pandey0fd8a42972de
diff --git a/litellm/integrations/SlackAlerting/slack_alerting.py b/litellm/integrations/SlackAlerting/slack_alerting.pyindex 94d734546be..432cbd0917b 100644--- a/litellm/integrations/SlackAlerting/slack_alerting.py+++ b/litellm/integrations/SlackAlerting/slack_alerting.py@@ -632,10 +632,10 @@ class SlackAlerting(CustomBatchLogger):event_message += f"Budget Crossed\n Total Budget:`{user_info.max_budget}`"elif percent_left <= SLACK_ALERTING_THRESHOLD_5_PERCENT:event = "threshold_crossed"- event_message += "5% Threshold Crossed "+ event_message += "5% or less of budget remaining"elif percent_left <= SLACK_ALERTING_THRESHOLD_15_PERCENT:event = "threshold_crossed"- event_message += "15% Threshold Crossed"+ event_message += "15% or less of budget remaining"return event, event_messagediff --git a/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.py b/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.pyindex 55e2dcdc270..6eaa3147dc3 100644--- a/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.py+++ b/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.py@@ -10,6 +10,7 @@ import pytestimport litellmfrom litellm.caching.caching import DualCache+from litellm.integrations.SlackAlerting.budget_alert_types import get_budget_alert_typefrom litellm.integrations.SlackAlerting.slack_alerting import SlackAlertingfrom litellm.proxy._types import CallInfo, Litellm_EntityTypefrom litellm.types.integrations.slack_alerting import AlertType, SlackAlertingCacheKeys@@ -46,9 +47,8 @@ class TestSlackAlerting(unittest.TestCase):self.assertEqual(result, -0.2)def test_get_event_and_event_message_max_budget(self):- # Initial setup with no eventevent = None- event_message = "Test Message: "+ event_message = get_budget_alert_type("user_budget").get_event_message()# Test case 1: When spend exceeds max_budgetuser_info = CallInfo(@@ -63,7 +63,7 @@ class TestSlackAlerting(unittest.TestCase):self.assertEqual(event, "budget_crossed")self.assertTrue("Budget Crossed" in event_message)- # Test case 2: When 5% of max_budget is left+ event_message = get_budget_alert_type("user_budget").get_event_message()user_info = CallInfo(max_budget=100.0,spend=95.0,@@ -74,9 +74,9 @@ class TestSlackAlerting(unittest.TestCase):user_info=user_info, event=event, event_message=event_message)self.assertEqual(event, "threshold_crossed")- self.assertTrue("5% Threshold Crossed" in event_message)+ self.assertEqual(event_message, "User Budget: 5% or less of budget remaining")- # Test case 3: When 15% of max_budget is left+ event_message = get_budget_alert_type("user_budget").get_event_message()user_info = CallInfo(max_budget=100.0,spend=85.0,@@ -87,7 +87,7 @@ class TestSlackAlerting(unittest.TestCase):user_info=user_info, event=event, event_message=event_message)self.assertEqual(event, "threshold_crossed")- self.assertTrue("15% Threshold Crossed" in event_message)+ self.assertEqual(event_message, "User Budget: 15% or less of budget remaining")def test_get_event_and_event_message_soft_budget(self):# Initial setup with no event