fix(utils.py): don't add chatml tokens to a simple text token count

This commit is contained in:
Krrish Dholakia 2024-03-28 13:48:34 -07:00
parent 75614bc29c
commit 5d428ac94c

View file

@ -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)