refactor: update retry exceptions to use openai instead of litellm

This commit is contained in:
Paul Gauthier 2024-10-28 14:40:42 -07:00 committed by Paul Gauthier (aider)
parent 8e2a4b47d6
commit 54d55c857b

View file

@ -18,25 +18,32 @@ RETRY_TIMEOUT = 60
def retry_exceptions(): def retry_exceptions():
import httpx import httpx
import openai
return ( return (
# httpx # httpx
httpx.ConnectError, httpx.ConnectError,
httpx.RemoteProtocolError, httpx.RemoteProtocolError,
httpx.ReadTimeout, httpx.ReadTimeout,
# litellm #
litellm.exceptions.AuthenticationError, # litellm exceptions inherit from openai exceptions
litellm.exceptions.PermissionDeniedError, # https://docs.litellm.ai/docs/exception_mapping
litellm.exceptions.NotFoundError, #
litellm.exceptions.UnprocessableEntityError, # openai.BadRequestError,
litellm.exceptions.RateLimitError, # litellm.ContextWindowExceededError,
litellm.exceptions.InternalServerError, # litellm.ContentPolicyViolationError,
litellm.exceptions.ContextWindowExceededError, #
litellm.exceptions.ContentPolicyViolationError, # openai.AuthenticationError,
litellm.exceptions.APIConnectionError, # openai.PermissionDeniedError,
litellm.exceptions.APIError, # openai.NotFoundError,
litellm.exceptions.ServiceUnavailableError, #
litellm.exceptions.Timeout, openai.APITimeoutError,
openai.UnprocessableEntityError,
openai.RateLimitError,
openai.APIConnectionError,
openai.APIError,
openai.APIStatusError,
openai.InternalServerError,
) )
@ -63,8 +70,6 @@ def send_completion(
temperature=0, temperature=0,
extra_params=None, extra_params=None,
): ):
from aider.llm import litellm
kwargs = dict( kwargs = dict(
model=model_name, model=model_name,
messages=messages, messages=messages,