mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-08 08:08:37 +00:00
get_retry_from_policy.py
This commit is contained in:
parent
0773bd200d
commit
d68499d916
1 changed files with 4 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue