forked from phoenix/litellm-mirror
feat: enable user to test slack budget alerting when creating a key
This commit is contained in:
parent
b7bf64eccf
commit
1ef19fbc9c
1 changed files with 37 additions and 0 deletions
|
@ -787,6 +787,7 @@ async def user_api_key_auth(
|
||||||
"/global/spend/keys",
|
"/global/spend/keys",
|
||||||
"/global/spend/models",
|
"/global/spend/models",
|
||||||
"/global/predict/spend/logs",
|
"/global/predict/spend/logs",
|
||||||
|
"/health/services",
|
||||||
]
|
]
|
||||||
# check if the current route startswith any of the allowed routes
|
# check if the current route startswith any of the allowed routes
|
||||||
if (
|
if (
|
||||||
|
@ -6479,6 +6480,42 @@ async def test_endpoint(request: Request):
|
||||||
return {"route": request.url.path}
|
return {"route": request.url.path}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(
|
||||||
|
"/health/services",
|
||||||
|
tags=["health"],
|
||||||
|
dependencies=[Depends(user_api_key_auth)],
|
||||||
|
include_in_schema=False,
|
||||||
|
)
|
||||||
|
async def health_services_endpoint(
|
||||||
|
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
|
||||||
|
service: Literal["slack_budget_alerts"] = fastapi.Query(
|
||||||
|
description="Specify the service being hit."
|
||||||
|
),
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Hidden endpoint.
|
||||||
|
|
||||||
|
Used by the UI to let user check if slack alerting is working as expected.
|
||||||
|
"""
|
||||||
|
global general_settings, proxy_logging_obj
|
||||||
|
|
||||||
|
if service is None:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400, detail={"error": "Service must be specified."}
|
||||||
|
)
|
||||||
|
|
||||||
|
if service not in ["slack_budget_alerts"]:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail={
|
||||||
|
"error": f"Service must be in list. Service={service}. List={['slack_budget_alerts']}"
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if "slack" in general_settings.get("alerting", []):
|
||||||
|
await proxy_logging_obj.alerting_handler(message="This is a test", level="Low")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/health", tags=["health"], dependencies=[Depends(user_api_key_auth)])
|
@router.get("/health", tags=["health"], dependencies=[Depends(user_api_key_auth)])
|
||||||
async def health_endpoint(
|
async def health_endpoint(
|
||||||
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
|
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue