Merge pull request #3426 from BerriAI/litellm_set_db_exceptions_on_ui

UI - set DB Exceptions webhook_url on UI
This commit is contained in:
Ishaan Jaff 2024-05-03 14:05:37 -07:00 committed by GitHub
commit e99edaf4e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 5 deletions

View file

@ -8708,11 +8708,11 @@ async def update_config(config_info: ConfigYAML):
# overwrite existing settings with updated values # overwrite existing settings with updated values
if k == "alert_to_webhook_url": if k == "alert_to_webhook_url":
# check if slack is already enabled. if not, enable it # 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"] _existing_settings["alerting"] = ["slack"]
elif isinstance(_existing_settings["alerting"], list):
_existing_settings["alerting"].append("slack")
_existing_settings[k] = v _existing_settings[k] = v
config["general_settings"] = _existing_settings config["general_settings"] = _existing_settings
@ -9197,6 +9197,37 @@ def _db_health_readiness_check():
return db_health_cache 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( @router.get(
"/health/readiness", "/health/readiness",
tags=["health"], tags=["health"],
@ -9206,6 +9237,7 @@ async def health_readiness():
""" """
Unprotected endpoint for checking if worker can receive requests Unprotected endpoint for checking if worker can receive requests
""" """
global general_settings
try: try:
# get success callback # get success callback
_num_callbacks = 0 _num_callbacks = 0

View file

@ -106,7 +106,8 @@ const Settings: React.FC<SettingsPageProps> = ({
"llm_exceptions": "LLM Exceptions", "llm_exceptions": "LLM Exceptions",
"llm_too_slow": "LLM Responses Too Slow", "llm_too_slow": "LLM Responses Too Slow",
"llm_requests_hanging": "LLM Requests Hanging", "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(() => { useEffect(() => {