From 54d55c857bc0b194702d47cd5e8d40e12ab92e39 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 28 Oct 2024 14:40:42 -0700 Subject: [PATCH] refactor: update retry exceptions to use openai instead of litellm --- aider/sendchat.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/aider/sendchat.py b/aider/sendchat.py index f860f2327..3ad22e743 100644 --- a/aider/sendchat.py +++ b/aider/sendchat.py @@ -18,25 +18,32 @@ RETRY_TIMEOUT = 60 def retry_exceptions(): import httpx + import openai return ( # httpx httpx.ConnectError, httpx.RemoteProtocolError, httpx.ReadTimeout, - # litellm - litellm.exceptions.AuthenticationError, - litellm.exceptions.PermissionDeniedError, - litellm.exceptions.NotFoundError, - litellm.exceptions.UnprocessableEntityError, - litellm.exceptions.RateLimitError, - litellm.exceptions.InternalServerError, - litellm.exceptions.ContextWindowExceededError, - litellm.exceptions.ContentPolicyViolationError, - litellm.exceptions.APIConnectionError, - litellm.exceptions.APIError, - litellm.exceptions.ServiceUnavailableError, - litellm.exceptions.Timeout, + # + # litellm exceptions inherit from openai exceptions + # https://docs.litellm.ai/docs/exception_mapping + # + # openai.BadRequestError, + # litellm.ContextWindowExceededError, + # litellm.ContentPolicyViolationError, + # + # openai.AuthenticationError, + # openai.PermissionDeniedError, + # openai.NotFoundError, + # + openai.APITimeoutError, + openai.UnprocessableEntityError, + openai.RateLimitError, + openai.APIConnectionError, + openai.APIError, + openai.APIStatusError, + openai.InternalServerError, ) @@ -63,8 +70,6 @@ def send_completion( temperature=0, extra_params=None, ): - from aider.llm import litellm - kwargs = dict( model=model_name, messages=messages,