Retry on litellm's APIError, which includes 502 (#4167)

This commit is contained in:
Engel Nyst 2024-10-03 01:54:49 +02:00 committed by Xingyao Wang
parent c2223a0fe4
commit 7da6e06da6

View File

@ -13,6 +13,7 @@ from litellm import completion as litellm_completion
from litellm import completion_cost as litellm_completion_cost
from litellm.exceptions import (
APIConnectionError,
APIError,
ContentPolicyViolationError,
InternalServerError,
NotFoundError,
@ -37,6 +38,14 @@ from openhands.core.metrics import Metrics
__all__ = ['LLM']
message_separator = '\n\n----------\n\n'
# tuple of exceptions to retry on
LLM_RETRY_EXCEPTIONS: tuple[type[Exception], ...] = (
APIConnectionError,
APIError,
InternalServerError,
RateLimitError,
ServiceUnavailableError,
)
cache_prompting_supported_models = [
'claude-3-5-sonnet-20240620',