From 104fd4d048fd5f50078d6baa04c188ad6922e102 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 11 May 2024 17:30:21 -0700 Subject: [PATCH] router - clean up should_retry_this_error --- litellm/router.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index f651b73d458..48a9703194e 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -1594,17 +1594,21 @@ class Router: _num_healthy_deployments = 0 if healthy_deployments is not None and isinstance(healthy_deployments, list): _num_healthy_deployments = len(healthy_deployments) + ### CHECK IF RATE LIMIT / CONTEXT WINDOW ERROR w/ fallbacks available / Bad Request Error + if ( isinstance(error, litellm.ContextWindowExceededError) - and context_window_fallbacks is not None - ) or ( - isinstance(error, openai.RateLimitError) - and fallbacks is not None - and _num_healthy_deployments <= 0 + and context_window_fallbacks is None ): 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): """ Try calling the function_with_retries