feat - set allowed fails policy

This commit is contained in:
Ishaan Jaff
2024-06-01 17:39:44 -07:00
parent eb203c051a
commit 4eaeec2a2d
2 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -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()
+2 -2
View File
@@ -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