mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-09 20:22:12 +00:00
feat - set allowed fails policy
This commit is contained in:
@@ -128,12 +128,17 @@ async def test_router_retries_errors(sync_mode, error_type):
|
||||
["AuthenticationErrorRetries", "ContentPolicyViolationErrorRetries"], #
|
||||
)
|
||||
async def test_router_retry_policy(error_type):
|
||||
from litellm.router import RetryPolicy
|
||||
from litellm.router import RetryPolicy, AllowedFailsPolicy
|
||||
|
||||
retry_policy = RetryPolicy(
|
||||
ContentPolicyViolationErrorRetries=3, AuthenticationErrorRetries=0
|
||||
)
|
||||
|
||||
allowed_fails_policy = AllowedFailsPolicy(
|
||||
ContentPolicyViolationErrorAllowedFails=1000,
|
||||
RateLimitErrorAllowedFails=100,
|
||||
)
|
||||
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
@@ -156,6 +161,7 @@ async def test_router_retry_policy(error_type):
|
||||
},
|
||||
],
|
||||
retry_policy=retry_policy,
|
||||
allowed_fails_policy=allowed_fails_policy,
|
||||
)
|
||||
|
||||
customHandler = MyCustomHandler()
|
||||
|
||||
@@ -385,8 +385,8 @@ class RouterErrors(enum.Enum):
|
||||
|
||||
class AllowedFailsPolicy(BaseModel):
|
||||
"""
|
||||
Use this to set a custom number of allowed_fails for each exception type before cooling down a deployment
|
||||
If RateLimitErrorRetries = 3, then 3 retries will be made for RateLimitError
|
||||
Use this to set a custom number of allowed fails/minute before cooling down a deployment
|
||||
If `AuthenticationErrorAllowedFails = 1000`, then 1000 AuthenticationError will be allowed before cooling down a deployment
|
||||
|
||||
Mapping of Exception type to allowed_fails for each exception
|
||||
https://docs.litellm.ai/docs/exception_mapping
|
||||
|
||||
Reference in New Issue
Block a user