get_retry_from_policy.py

This commit is contained in:
Siraj637909 2026-08-14 20:16:14 +05:30 • committed by GitHub
parent 0773bd200d
commit d68499d916
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ from litellm.exceptions import (
AuthenticationError,
BadRequestError,
ContentPolicyViolationError,
NotFoundError,
RateLimitError,
Timeout,
)
@ -26,6 +27,7 @@ def get_num_retries_from_retry_policy(
TimeoutErrorRetries: Optional[int] = None
RateLimitErrorRetries: Optional[int] = None
ContentPolicyViolationErrorRetries: Optional[int] = None
NotFoundErrorRetries: Optional[int] = None
"""
# if we can find the exception then in the retry policy -> return the number of retries
@ -50,6 +52,8 @@ def get_num_retries_from_retry_policy(
return retry_policy.ContentPolicyViolationErrorRetries
if isinstance(exception, BadRequestError) and retry_policy.BadRequestErrorRetries is not None:
return retry_policy.BadRequestErrorRetries
if isinstance(exception, NotFoundError) and retry_policy.NotFoundErrorRetries is not None:
return retry_policy.NotFoundErrorRetries
def reset_retry_policy() -> RetryPolicy: