mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
router - clean up should_retry_this_error
This commit is contained in:
parent
6a967b3267
commit
9ca793fffd
1 changed files with 9 additions and 5 deletions
|
@ -1594,17 +1594,21 @@ class Router:
|
||||||
_num_healthy_deployments = 0
|
_num_healthy_deployments = 0
|
||||||
if healthy_deployments is not None and isinstance(healthy_deployments, list):
|
if healthy_deployments is not None and isinstance(healthy_deployments, list):
|
||||||
_num_healthy_deployments = len(healthy_deployments)
|
_num_healthy_deployments = len(healthy_deployments)
|
||||||
|
|
||||||
### CHECK IF RATE LIMIT / CONTEXT WINDOW ERROR w/ fallbacks available / Bad Request Error
|
### CHECK IF RATE LIMIT / CONTEXT WINDOW ERROR w/ fallbacks available / Bad Request Error
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isinstance(error, litellm.ContextWindowExceededError)
|
isinstance(error, litellm.ContextWindowExceededError)
|
||||||
and context_window_fallbacks is not None
|
and context_window_fallbacks is None
|
||||||
) or (
|
|
||||||
isinstance(error, openai.RateLimitError)
|
|
||||||
and fallbacks is not None
|
|
||||||
and _num_healthy_deployments <= 0
|
|
||||||
):
|
):
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
|
if isinstance(error, openai.RateLimitError):
|
||||||
|
if fallbacks is None and _num_healthy_deployments <= 0:
|
||||||
|
raise error
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def function_with_fallbacks(self, *args, **kwargs):
|
def function_with_fallbacks(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Try calling the function_with_retries
|
Try calling the function_with_retries
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue