From c7b6911c7b9a2f596be9a0d021739b5e64d193ab Mon Sep 17 00:00:00 2001 From: mc-marcocheng Date: Tue, 31 Oct 2023 14:38:04 +0800 Subject: [PATCH] Handle empty input edge case --- litellm/router.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index c4997e3d5f..970daaf51b 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -162,9 +162,10 @@ class Router: current_tpm, current_rpm = self._get_deployment_usage(deployment_name=deployment["litellm_params"]["model"]) # get encoding - if messages: + token_count = 0 + if messages is not None: token_count = litellm.token_counter(model=deployment["model_name"], messages=messages) - elif input: + elif input is not None: if isinstance(input, List): input_text = "".join(text for text in input) else: