Merge branch 'main' into litellm_global_spend_updates

This commit is contained in:
Krish Dholakia 2024-01-24 20:20:15 -08:00 committed by GitHub
commit 6501fdb76e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 166 additions and 24 deletions

View file

@ -2877,8 +2877,13 @@ def token_counter(
print_verbose(
f"Token Counter - using generic token counter, for model={model}"
)
enc = tokenizer_json["tokenizer"].encode(text)
num_tokens = len(enc)
num_tokens = openai_token_counter(
text=text, # type: ignore
model="gpt-3.5-turbo",
messages=messages,
is_tool_call=is_tool_call,
count_response_tokens=count_response_tokens,
)
else:
num_tokens = len(encoding.encode(text)) # type: ignore
return num_tokens