From c365de122a2af998c8d11c9473bf163bb3ddd737 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 30 Mar 2024 19:33:40 -0700 Subject: [PATCH] check num retries in async wrapper --- litellm/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/litellm/utils.py b/litellm/utils.py index 2a765bc41d6..600d8059913 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2515,6 +2515,16 @@ def client(original_function): or kwargs.get("atext_completion", False) == True or kwargs.get("atranscription", False) == True ): + # [OPTIONAL] CHECK MAX RETRIES / REQUEST + if litellm.num_retries_per_request is not None: + # check if previous_models passed in as ['litellm_params']['metadata]['previous_models'] + previous_models = kwargs.get("metadata", {}).get( + "previous_models", None + ) + if previous_models is not None: + if litellm.num_retries_per_request <= len(previous_models): + raise Exception(f"Max retries per request hit!") + # MODEL CALL result = original_function(*args, **kwargs) if "stream" in kwargs and kwargs["stream"] == True: