mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 10:14:26 +00:00
polish tiktoken encoding_for_model
This commit is contained in:
parent
07c5f136f1
commit
6e6849f416
1 changed files with 1 additions and 4 deletions
|
@ -1360,10 +1360,7 @@ def openai_token_counter( # noqa: PLR0915
|
|||
"""
|
||||
print_verbose(f"LiteLLM: Utils - Counting tokens for OpenAI model={model}")
|
||||
try:
|
||||
if "gpt-4o" in model:
|
||||
encoding = tiktoken.get_encoding("o200k_base")
|
||||
else:
|
||||
encoding = tiktoken.encoding_for_model(model)
|
||||
encoding = tiktoken.encoding_for_model(model)
|
||||
except KeyError:
|
||||
print_verbose("Warning: model not found. Using cl100k_base encoding.")
|
||||
encoding = tiktoken.get_encoding("cl100k_base")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue