diff --git a/litellm/tests/test_alerting.py b/litellm/tests/test_alerting.py index 9dfec3dcfa..0cbf6cb6d3 100644 --- a/litellm/tests/test_alerting.py +++ b/litellm/tests/test_alerting.py @@ -25,6 +25,9 @@ import pytest from litellm.router import AlertingConfig, Router from litellm.proxy._types import CallInfo from openai import APIError +from litellm.router import AlertingConfig +import litellm +import os @pytest.mark.parametrize( @@ -743,3 +746,37 @@ async def test_region_outage_alerting_called( mock_send_alert.assert_called_once() else: mock_send_alert.assert_not_called() + + +@pytest.mark.asyncio +@pytest.mark.skip(reason="test only needs to run locally ") +async def test_alerting(): + router = litellm.Router( + model_list=[ + { + "model_name": "gpt-3.5-turbo", + "litellm_params": { + "model": "gpt-3.5-turbo", + "api_key": "bad_key", + }, + } + ], + debug_level="DEBUG", + set_verbose=True, + alerting_config=AlertingConfig( + alerting_threshold=10, # threshold for slow / hanging llm responses (in seconds). Defaults to 300 seconds + webhook_url=os.getenv( + "SLACK_WEBHOOK_URL" + ), # webhook you want to send alerts to + ), + ) + try: + await router.acompletion( + model="gpt-3.5-turbo", + messages=[{"role": "user", "content": "Hey, how's it going?"}], + ) + + except: + pass + finally: + await asyncio.sleep(3)