(feat proxy slack alerting) - allow opting in to getting key / internal user alerts (#5990)

* define all slack alert types

* use correct type hints for alert type

* use correct defaults on slack alerting

* add readme for slack alerting

* fix linting error

* update readme

* docs all alert types

* update slack alerting docs

* fix slack alerting docs

* handle new testing dir structure

* fix config for testing

* fix testing folder related imports

* fix /tests import errors

* fix import stream_chunk_testdata

* docs alert types

* fix test test_langfuse_trace_id

* fix type checks for slack alerting

* fix outage alerting test slack
This commit is contained in:
Ishaan Jaff 2024-10-01 10:49:22 -07:00 committed by GitHub
parent 8225880af0
commit 045ecf3ffb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 283 additions and 210 deletions

View file

@ -14,6 +14,8 @@ from typing import Optional
import httpx
from litellm.integrations.SlackAlerting.types import AlertType
# import logging
# logging.basicConfig(level=logging.DEBUG)
sys.path.insert(0, os.path.abspath("../.."))
@ -99,7 +101,7 @@ async def test_get_api_base():
await _pl.alerting_handler(
message=slow_message + request_info,
level="Low",
alert_type="llm_too_slow",
alert_type=AlertType.llm_too_slow,
)
print("passed test_get_api_base")
@ -117,7 +119,7 @@ def test_init():
slack_alerting = SlackAlerting(
alerting_threshold=32,
alerting=["slack"],
alert_types=["llm_exceptions"],
alert_types=[AlertType.llm_exceptions],
internal_usage_cache=DualCache(),
)
assert slack_alerting.alerting_threshold == 32
@ -710,7 +712,7 @@ async def test_region_outage_alerting_called(
If multiple calls fail, outage alert is sent
"""
slack_alerting = SlackAlerting(
alerting=["webhook"], alert_types=["region_outage_alerts"]
alerting=["webhook"], alert_types=[AlertType.region_outage_alerts]
)
litellm.callbacks = [slack_alerting]
@ -829,6 +831,7 @@ async def test_langfuse_trace_id():
- Unit test for `_add_langfuse_trace_id_to_alert` function in slack_alerting.py
"""
from litellm.litellm_core_utils.litellm_logging import Logging
from litellm.integrations.SlackAlerting.utils import _add_langfuse_trace_id_to_alert
litellm.success_callback = ["langfuse"]
@ -856,11 +859,11 @@ async def test_langfuse_trace_id():
slack_alerting = SlackAlerting(
alerting_threshold=32,
alerting=["slack"],
alert_types=["llm_exceptions"],
alert_types=[AlertType.llm_exceptions],
internal_usage_cache=DualCache(),
)
trace_url = await slack_alerting._add_langfuse_trace_id_to_alert(
trace_url = await _add_langfuse_trace_id_to_alert(
request_data={"litellm_logging_obj": litellm_logging_obj}
)