mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
feat - set allowed fails policy
This commit is contained in:
parent
eb203c051a
commit
4eaeec2a2d
2 changed files with 9 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue