fix(router.py): fix int logic

This commit is contained in:
Krrish Dholakia 2023-12-29 20:41:56 +05:30
parent cf91e49c87
commit 2fc264ca04
3 changed files with 11 additions and 3 deletions

View file

@ -1546,9 +1546,11 @@ class Router:
############## Available Deployments passed, we find the relevant item ################# ############## Available Deployments passed, we find the relevant item #################
else: else:
## check if min deployment is a string, if so, cast it to int ## check if min deployment is a string, if so, cast it to int
if isinstance(min_deployment, str):
min_deployment = int(min_deployment)
for m in healthy_deployments: for m in healthy_deployments:
if isinstance(min_deployment, str) and isinstance(
m["model_info"]["id"], int
):
min_deployment = int(min_deployment)
if m["model_info"]["id"] == min_deployment: if m["model_info"]["id"] == min_deployment:
return m return m
self.print_verbose(f"no healthy deployment with that id found!") self.print_verbose(f"no healthy deployment with that id found!")

View file

@ -66,6 +66,7 @@ class LowestTPMLoggingHandler(CustomLogger):
if self.test_flag: if self.test_flag:
self.logged_success += 1 self.logged_success += 1
except Exception as e: except Exception as e:
traceback.print_exc()
pass pass
async def async_log_success_event(self, kwargs, response_obj, start_time, end_time): async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):
@ -114,6 +115,7 @@ class LowestTPMLoggingHandler(CustomLogger):
if self.test_flag: if self.test_flag:
self.logged_success += 1 self.logged_success += 1
except Exception as e: except Exception as e:
traceback.print_exc()
pass pass
def get_available_deployments(self, model_group: str): def get_available_deployments(self, model_group: str):

View file

@ -149,7 +149,7 @@ async def test_acompletion_caching_with_ttl_on_router():
async def test_acompletion_caching_on_router_caching_groups(): async def test_acompletion_caching_on_router_caching_groups():
# tests acompletion + caching on router # tests acompletion + caching on router
try: try:
litellm.set_verbose = True # litellm.set_verbose = True
model_list = [ model_list = [
{ {
"model_name": "openai-gpt-3.5-turbo", "model_name": "openai-gpt-3.5-turbo",
@ -212,6 +212,7 @@ async def test_acompletion_caching_on_router_caching_groups():
def test_usage_based_routing_completion(): def test_usage_based_routing_completion():
litellm.set_verbose = True
model_list = [ model_list = [
{ {
"model_name": "gpt-3.5-turbo", "model_name": "gpt-3.5-turbo",
@ -249,3 +250,6 @@ def test_usage_based_routing_completion():
finally: finally:
max_requests -= 1 max_requests -= 1
router.reset() router.reset()
test_usage_based_routing_completion()