mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-17 23:51:30 +00:00
fix: skip token counting for multimodal inputs in process_response
This commit is contained in:
parent
9c4c34177e
commit
bb247685da
2 changed files with 6 additions and 3 deletions
|
|
@ -312,8 +312,11 @@ def process_response(
|
|||
model_response.data = openai_embeddings
|
||||
model_response.model = model
|
||||
|
||||
input_text = get_formatted_prompt(data={"input": input}, call_type="embedding")
|
||||
prompt_tokens = token_counter(model=model, text=input_text)
|
||||
if _is_multimodal_input(input):
|
||||
prompt_tokens = 0
|
||||
else:
|
||||
input_text = get_formatted_prompt(data={"input": input}, call_type="embedding")
|
||||
prompt_tokens = token_counter(model=model, text=input_text)
|
||||
model_response.usage = Usage(
|
||||
prompt_tokens=prompt_tokens, total_tokens=prompt_tokens
|
||||
)
|
||||
|
|
|
|||
|
|
@ -192,4 +192,4 @@ class TestProcessResponse:
|
|||
assert len(result.data) == 2
|
||||
assert result.data[0]["index"] == 0
|
||||
assert result.data[1]["index"] == 1
|
||||
assert result.usage.prompt_tokens >= 0
|
||||
assert result.usage.prompt_tokens == 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue