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: update alert type formatting to handle enum names in Slack messages
Marcelo Mendozadb1b418b1568
diff --git a/litellm/integrations/SlackAlerting/slack_alerting.py b/litellm/integrations/SlackAlerting/slack_alerting.pyindex 6d705642667..7da38e193b6 100644--- a/litellm/integrations/SlackAlerting/slack_alerting.py+++ b/litellm/integrations/SlackAlerting/slack_alerting.py@@ -1367,7 +1367,9 @@ Model Info:# Get the current timestampcurrent_time = datetime.now().strftime("%H:%M:%S")_proxy_base_url = os.getenv("PROXY_BASE_URL", None)- alert_type_formatted = f"Alert type: `{alert_type}`\n"+ # Use .name if it's an enum, otherwise use as is+ alert_type_name = getattr(alert_type, 'name', alert_type)+ alert_type_formatted = f"Alert type: `{alert_type_name}`"if alert_type == "daily_reports" or alert_type == "new_model_added":formatted_message = alert_type_formatted + messageelse:diff --git a/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.py b/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.pyindex 7e1bd897908..9cccdb51799 100644--- a/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.py+++ b/tests/test_litellm/integrations/SlackAlerting/test_slack_alerting.py@@ -188,11 +188,11 @@ class TestSlackAlerting(unittest.TestCase):current_time = "12:34:56"# Test the specific formatting logic we're interested in- alert_type_formatted = f"Alert type: `{alert_type}`\n"+ alert_type_formatted = f"Alert type: `{alert_type.name}`\n"formatted_message = f"{alert_type_formatted}\n Level: `{level}`\nTimestamp: `{current_time}`\n\nMessage: {message}"# Verify alert_type is in the formatted message as expected- self.assertIn("Alert type: `AlertType.llm_exceptions`", formatted_message)+ self.assertIn("Alert type: `llm_exceptions`", formatted_message)self.assertIn("Level: `Medium`", formatted_message)self.assertIn("Timestamp: `12:34:56`", formatted_message)self.assertIn("Message: Test alert message", formatted_message)