From 7c9c4fe78885f6f9878abc9ba897cd9d9ac213e6 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 4 May 2024 17:43:26 -0700 Subject: [PATCH] should_giveup? --- aider/sendchat.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aider/sendchat.py b/aider/sendchat.py index a341993ad..3bb74a1a0 100644 --- a/aider/sendchat.py +++ b/aider/sendchat.py @@ -18,6 +18,13 @@ CACHE = None litellm.suppress_debug_info = True +def should_giveup(e): + if not hasattr(e, "status_code"): + return False + + return not litellm._should_retry(e.status_code) + + @backoff.on_exception( backoff.expo, ( @@ -28,7 +35,8 @@ litellm.suppress_debug_info = True httpx.RemoteProtocolError, litellm.exceptions.ServiceUnavailableError, ), - max_tries=10, + giveup=should_giveup, + max_tries=3, on_backoff=lambda details: print( f"{details.get('exception','Exception')}\nRetry in {details['wait']:.1f} seconds." ),