mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
Stop using litellm._should_retry
This commit is contained in:
parent
f4d0864bcb
commit
1e232d4db6
1 changed files with 0 additions and 22 deletions
|
@ -18,27 +18,6 @@ def lazy_litellm_retry_decorator(func):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
def should_giveup(e):
|
|
||||||
if not hasattr(e, "status_code"):
|
|
||||||
return False
|
|
||||||
|
|
||||||
if type(e) in (
|
|
||||||
httpx.ConnectError,
|
|
||||||
httpx.RemoteProtocolError,
|
|
||||||
httpx.ReadTimeout,
|
|
||||||
):
|
|
||||||
return False
|
|
||||||
|
|
||||||
# These seem to return .status_code = ""
|
|
||||||
# litellm._should_retry() expects an int and throws a TypeError
|
|
||||||
#
|
|
||||||
# litellm.llms.anthropic.AnthropicError
|
|
||||||
# litellm.exceptions.APIError
|
|
||||||
if not e.status_code:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return not litellm._should_retry(e.status_code)
|
|
||||||
|
|
||||||
decorated_func = backoff.on_exception(
|
decorated_func = backoff.on_exception(
|
||||||
backoff.expo,
|
backoff.expo,
|
||||||
(
|
(
|
||||||
|
@ -53,7 +32,6 @@ def lazy_litellm_retry_decorator(func):
|
||||||
litellm.exceptions.InternalServerError,
|
litellm.exceptions.InternalServerError,
|
||||||
litellm.llms.anthropic.AnthropicError,
|
litellm.llms.anthropic.AnthropicError,
|
||||||
),
|
),
|
||||||
giveup=should_giveup,
|
|
||||||
max_time=60,
|
max_time=60,
|
||||||
on_backoff=lambda details: print(
|
on_backoff=lambda details: print(
|
||||||
f"{details.get('exception', 'Exception')}\nRetry in {details['wait']:.1f} seconds."
|
f"{details.get('exception', 'Exception')}\nRetry in {details['wait']:.1f} seconds."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue