From 0a2cb9555c9f60397757045ce064fc13f896e0a6 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 c4997e3d5fd..970daaf51ba 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: