Merge pull request #3335 from BerriAI/litellm_fix_ui_cross_global_budget

Fix -  Admin UI stops working if proxy budget has been exceeded
This commit is contained in:
Ishaan Jaff 2024-04-27 14:18:12 -07:00 committed by GitHub
commit f31d3c4e9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -95,7 +95,15 @@ def common_checks(
f"'user' param not passed in. 'enforce_user_param'={general_settings['enforce_user_param']}"
)
# 7. [OPTIONAL] If 'litellm.max_budget' is set (>0), is proxy under budget
if litellm.max_budget > 0 and global_proxy_spend is not None:
if (
litellm.max_budget > 0
and global_proxy_spend is not None
# only run global budget checks for OpenAI routes
# Reason - the Admin UI should continue working if the proxy crosses it's global budget
and route in LiteLLMRoutes.openai_routes.value
and route != "/v1/models"
and route != "/models"
):
if global_proxy_spend > litellm.max_budget:
raise Exception(
f"ExceededBudget: LiteLLM Proxy has exceeded its budget. Current spend: {global_proxy_spend}; Max Budget: {litellm.max_budget}"