mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
Improve validate-fallbacks method
* No need to check for fallback_params length * Instead of asserting, used if condition and raised valueError * Improved Error message
This commit is contained in:
parent
fb5a6e97c9
commit
45dd4d37d0
1 changed files with 7 additions and 11 deletions
|
@ -348,17 +348,13 @@ class Router:
|
||||||
def validate_fallbacks(self, fallback_param: Optional[List]):
|
def validate_fallbacks(self, fallback_param: Optional[List]):
|
||||||
if fallback_param is None:
|
if fallback_param is None:
|
||||||
return
|
return
|
||||||
if len(fallback_param) > 0: # if set
|
|
||||||
## for dictionary in list, check if only 1 key in dict
|
for fallback_dict in fallback_param:
|
||||||
for _dict in fallback_param:
|
if not isinstance(fallback_dict, dict):
|
||||||
assert isinstance(_dict, dict), "Item={}, not a dictionary".format(
|
raise ValueError(f"Item '{fallback_dict}' is not a dictionary.")
|
||||||
_dict
|
if len(fallback_dict) != 1:
|
||||||
)
|
raise ValueError(
|
||||||
assert (
|
f"Dictionary '{fallback_dict}' must have exactly one key, but has {len(fallback_dict)} keys.")
|
||||||
len(_dict.keys()) == 1
|
|
||||||
), "Only 1 key allows in dictionary. You set={} for dict={}".format(
|
|
||||||
len(_dict.keys()), _dict
|
|
||||||
)
|
|
||||||
|
|
||||||
def routing_strategy_init(self, routing_strategy: str, routing_strategy_args: dict):
|
def routing_strategy_init(self, routing_strategy: str, routing_strategy_args: dict):
|
||||||
if routing_strategy == "least-busy":
|
if routing_strategy == "least-busy":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue