diff --git a/litellm/utils.py b/litellm/utils.py index 88b952031..fa15b73c2 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3597,6 +3597,8 @@ def token_counter( raise ValueError("text and messages cannot both be None") elif isinstance(text, List): text = "".join(t for t in text if isinstance(t, str)) + elif isinstance(text, str): + count_response_tokens = True # user just trying to count tokens for a text. don't add the chat_ml +3 tokens to this if model is not None: tokenizer_json = _select_tokenizer(model=model)