mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
fix token counter bug
This commit is contained in:
parent
2e95758ada
commit
f4c49755a0
1 changed files with 1 additions and 0 deletions
|
@ -4060,6 +4060,7 @@ def openai_token_counter(
|
||||||
for c in value:
|
for c in value:
|
||||||
if c["type"] == "text":
|
if c["type"] == "text":
|
||||||
text += c["text"]
|
text += c["text"]
|
||||||
|
num_tokens += len(encoding.encode(c["text"], disallowed_special=()))
|
||||||
elif c["type"] == "image_url":
|
elif c["type"] == "image_url":
|
||||||
if isinstance(c["image_url"], dict):
|
if isinstance(c["image_url"], dict):
|
||||||
image_url_dict = c["image_url"]
|
image_url_dict = c["image_url"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue