From fdc9856652364d138deeaade517ae36eecd787e5 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 3 May 2024 13:33:43 -0700 Subject: [PATCH 1/2] UI - set DB Exceptions webhook_url --- ui/litellm-dashboard/src/components/settings.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/settings.tsx b/ui/litellm-dashboard/src/components/settings.tsx index 53de36286..092f7bb14 100644 --- a/ui/litellm-dashboard/src/components/settings.tsx +++ b/ui/litellm-dashboard/src/components/settings.tsx @@ -106,7 +106,8 @@ const Settings: React.FC = ({ "llm_exceptions": "LLM Exceptions", "llm_too_slow": "LLM Responses Too Slow", "llm_requests_hanging": "LLM Requests Hanging", - "budget_alerts": "Budget Alerts (API Keys, Users)" + "budget_alerts": "Budget Alerts (API Keys, Users)", + "db_exceptions": "Database Exceptions (Read/Write)", } useEffect(() => { From 776f541f6ceca750383ecb399083e175c192c1cb Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 3 May 2024 14:04:38 -0700 Subject: [PATCH 2/2] fix bug where slack would get inserting several times --- litellm/proxy/proxy_server.py | 40 +++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 26987f478..763094fde 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -8708,11 +8708,11 @@ async def update_config(config_info: ConfigYAML): # overwrite existing settings with updated values if k == "alert_to_webhook_url": # check if slack is already enabled. if not, enable it - if "slack" not in _existing_settings: - if "alerting" not in _existing_settings: + if "alerting" not in _existing_settings: + _existing_settings["alerting"] = ["slack"] + elif isinstance(_existing_settings["alerting"], list): + if "slack" not in _existing_settings["alerting"]: _existing_settings["alerting"] = ["slack"] - elif isinstance(_existing_settings["alerting"], list): - _existing_settings["alerting"].append("slack") _existing_settings[k] = v config["general_settings"] = _existing_settings @@ -9197,6 +9197,37 @@ def _db_health_readiness_check(): return db_health_cache +@router.get( + "/active/callbacks", + tags=["health"], + dependencies=[Depends(user_api_key_auth)], +) +async def active_callbacks(): + _alerting = str(general_settings.get("alerting")) + # get success callback + success_callback_names = [] + try: + # this was returning a JSON of the values in some of the callbacks + # all we need is the callback name, hence we do str(callback) + success_callback_names = [str(x) for x in litellm.success_callback] + except: + # don't let this block the /health/readiness response, if we can't convert to str -> return litellm.success_callback + success_callback_names = litellm.success_callback + + _num_callbacks = ( + len(litellm.callbacks) + + len(litellm.input_callback) + + len(litellm.failure_callback) + + len(litellm.success_callback) + ) + + return { + "alerting": _alerting, + "success_callbacks": success_callback_names, + "num_callbacks": _num_callbacks, + } + + @router.get( "/health/readiness", tags=["health"], @@ -9206,6 +9237,7 @@ async def health_readiness(): """ Unprotected endpoint for checking if worker can receive requests """ + global general_settings try: # get success callback success_callback_names = []