mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix(router.py): fix should_retry logic for authentication errors
This commit is contained in:
parent
872cd2d8a0
commit
a019fd05e3
2 changed files with 13 additions and 8 deletions
|
@ -2154,7 +2154,6 @@ class Router:
|
|||
- there are no fallbacks
|
||||
- there are no healthy deployments in the same model group
|
||||
"""
|
||||
|
||||
_num_healthy_deployments = 0
|
||||
if healthy_deployments is not None and isinstance(healthy_deployments, list):
|
||||
_num_healthy_deployments = len(healthy_deployments)
|
||||
|
@ -2167,15 +2166,21 @@ class Router:
|
|||
raise error
|
||||
|
||||
# Error we should only retry if there are other deployments
|
||||
if isinstance(error, openai.RateLimitError) or isinstance(
|
||||
error, openai.AuthenticationError
|
||||
):
|
||||
if isinstance(error, openai.RateLimitError):
|
||||
if (
|
||||
_num_healthy_deployments <= 0
|
||||
and regular_fallbacks is not None
|
||||
_num_healthy_deployments <= 0 # if no healthy deployments
|
||||
and regular_fallbacks is not None # and fallbacks available
|
||||
and len(regular_fallbacks) > 0
|
||||
):
|
||||
raise error
|
||||
raise error # then raise the error
|
||||
|
||||
if isinstance(error, openai.AuthenticationError):
|
||||
"""
|
||||
- if other deployments available -> retry
|
||||
- else -> raise error
|
||||
"""
|
||||
if _num_healthy_deployments <= 0: # if no healthy deployments
|
||||
raise error # then raise error
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue