@@ -359,9 +359,9 @@ def __init__( # noqa: PLR0915
359
359
) # names of models under litellm_params. ex. azure/chatgpt-v-2
360
360
self .deployment_latency_map = {}
361
361
### CACHING ###
362
- cache_type : Literal [
363
- "local" , "redis" , "redis-semantic" , "s3" , "disk"
364
- ] = "local" # default to an in-memory cache
362
+ cache_type : Literal ["local" , "redis" , "redis-semantic" , "s3" , "disk" ] = (
363
+ "local" # default to an in-memory cache
364
+ )
365
365
redis_cache = None
366
366
cache_config : Dict [str , Any ] = {}
367
367
@@ -403,9 +403,9 @@ def __init__( # noqa: PLR0915
403
403
self .default_max_parallel_requests = default_max_parallel_requests
404
404
self .provider_default_deployment_ids : List [str ] = []
405
405
self .pattern_router = PatternMatchRouter ()
406
- self .team_pattern_routers : Dict [
407
- str , PatternMatchRouter
408
- ] = {} # {"TEAM_ID": PatternMatchRouter}
406
+ self .team_pattern_routers : Dict [str , PatternMatchRouter ] = (
407
+ {}
408
+ ) # {"TEAM_ID": PatternMatchRouter}
409
409
self .auto_routers : Dict [str , "AutoRouter" ] = {}
410
410
411
411
if model_list is not None :
@@ -587,9 +587,9 @@ def __init__( # noqa: PLR0915
587
587
)
588
588
)
589
589
590
- self .model_group_retry_policy : Optional [
591
- Dict [ str , RetryPolicy ]
592
- ] = model_group_retry_policy
590
+ self .model_group_retry_policy : Optional [Dict [ str , RetryPolicy ]] = (
591
+ model_group_retry_policy
592
+ )
593
593
594
594
self .allowed_fails_policy : Optional [AllowedFailsPolicy ] = None
595
595
if allowed_fails_policy is not None :
@@ -1211,7 +1211,10 @@ async def stream_with_fallbacks():
1211
1211
1212
1212
async def _acompletion (
1213
1213
self , model : str , messages : List [Dict [str , str ]], ** kwargs
1214
- ) -> Union [ModelResponse , CustomStreamWrapper ,]:
1214
+ ) -> Union [
1215
+ ModelResponse ,
1216
+ CustomStreamWrapper ,
1217
+ ]:
1215
1218
"""
1216
1219
- Get an available deployment
1217
1220
- call it with a semaphore over the call
@@ -3155,9 +3158,9 @@ async def create_file_for_deployment(deployment: dict) -> OpenAIFileObject:
3155
3158
healthy_deployments = healthy_deployments , responses = responses
3156
3159
)
3157
3160
returned_response = cast (OpenAIFileObject , responses [0 ])
3158
- returned_response ._hidden_params [
3159
- " model_file_id_mapping"
3160
- ] = model_file_id_mapping
3161
+ returned_response ._hidden_params ["model_file_id_mapping" ] = (
3162
+ model_file_id_mapping
3163
+ )
3161
3164
return returned_response
3162
3165
except Exception as e :
3163
3166
verbose_router_logger .exception (
@@ -3720,11 +3723,11 @@ async def async_function_with_fallbacks_common_utils( # noqa: PLR0915
3720
3723
3721
3724
if isinstance (e , litellm .ContextWindowExceededError ):
3722
3725
if context_window_fallbacks is not None :
3723
- context_window_fallback_model_group : Optional [
3724
- List [ str ]
3725
- ] = self . _get_fallback_model_group_from_fallbacks (
3726
- fallbacks = context_window_fallbacks ,
3727
- model_group = model_group ,
3726
+ context_window_fallback_model_group : Optional [List [ str ]] = (
3727
+ self . _get_fallback_model_group_from_fallbacks (
3728
+ fallbacks = context_window_fallbacks ,
3729
+ model_group = model_group ,
3730
+ )
3728
3731
)
3729
3732
if context_window_fallback_model_group is None :
3730
3733
raise original_exception
@@ -3756,11 +3759,11 @@ async def async_function_with_fallbacks_common_utils( # noqa: PLR0915
3756
3759
e .message += "\n {}" .format (error_message )
3757
3760
elif isinstance (e , litellm .ContentPolicyViolationError ):
3758
3761
if content_policy_fallbacks is not None :
3759
- content_policy_fallback_model_group : Optional [
3760
- List [ str ]
3761
- ] = self . _get_fallback_model_group_from_fallbacks (
3762
- fallbacks = content_policy_fallbacks ,
3763
- model_group = model_group ,
3762
+ content_policy_fallback_model_group : Optional [List [ str ]] = (
3763
+ self . _get_fallback_model_group_from_fallbacks (
3764
+ fallbacks = content_policy_fallbacks ,
3765
+ model_group = model_group ,
3766
+ )
3764
3767
)
3765
3768
if content_policy_fallback_model_group is None :
3766
3769
raise original_exception
@@ -4414,7 +4417,7 @@ async def deployment_callback_on_success(
4414
4417
return tpm_key
4415
4418
4416
4419
except Exception as e :
4417
- verbose_router_logger .exception (
4420
+ verbose_router_logger .debug (
4418
4421
"litellm.router.Router::deployment_callback_on_success(): Exception occured - {}" .format (
4419
4422
str (e )
4420
4423
)
@@ -4992,26 +4995,26 @@ def init_auto_router_deployment(self, deployment: Deployment):
4992
4995
"""
4993
4996
from litellm .router_strategy .auto_router .auto_router import AutoRouter
4994
4997
4995
- auto_router_config_path : Optional [
4996
- str
4997
- ] = deployment . litellm_params . auto_router_config_path
4998
+ auto_router_config_path : Optional [str ] = (
4999
+ deployment . litellm_params . auto_router_config_path
5000
+ )
4998
5001
auto_router_config : Optional [str ] = deployment .litellm_params .auto_router_config
4999
5002
if auto_router_config_path is None and auto_router_config is None :
5000
5003
raise ValueError (
5001
5004
"auto_router_config_path or auto_router_config is required for auto-router deployments. Please set it in the litellm_params"
5002
5005
)
5003
5006
5004
- default_model : Optional [
5005
- str
5006
- ] = deployment . litellm_params . auto_router_default_model
5007
+ default_model : Optional [str ] = (
5008
+ deployment . litellm_params . auto_router_default_model
5009
+ )
5007
5010
if default_model is None :
5008
5011
raise ValueError (
5009
5012
"auto_router_default_model is required for auto-router deployments. Please set it in the litellm_params"
5010
5013
)
5011
5014
5012
- embedding_model : Optional [
5013
- str
5014
- ] = deployment . litellm_params . auto_router_embedding_model
5015
+ embedding_model : Optional [str ] = (
5016
+ deployment . litellm_params . auto_router_embedding_model
5017
+ )
5015
5018
if embedding_model is None :
5016
5019
raise ValueError (
5017
5020
"auto_router_embedding_model is required for auto-router deployments. Please set it in the litellm_params"
0 commit comments