mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
fix(cost): coerce at parameter so all downstream uses see clean counts
This commit is contained in:
parent
ab3f12410e
commit
cc2d9f10df
1 changed files with 5 additions and 5 deletions
|
|
@ -378,17 +378,17 @@ def cost_per_token(
|
|||
if model is None:
|
||||
raise Exception("Invalid arg. Model cannot be none.")
|
||||
|
||||
coerced_prompt_tokens = _coerce_token_count(prompt_tokens)
|
||||
coerced_completion_tokens = _coerce_token_count(completion_tokens)
|
||||
prompt_tokens = _coerce_token_count(prompt_tokens)
|
||||
completion_tokens = _coerce_token_count(completion_tokens)
|
||||
|
||||
## RECONSTRUCT USAGE BLOCK ##
|
||||
if usage_object is not None:
|
||||
usage_block = usage_object
|
||||
else:
|
||||
usage_block = Usage(
|
||||
prompt_tokens=coerced_prompt_tokens,
|
||||
completion_tokens=coerced_completion_tokens,
|
||||
total_tokens=coerced_prompt_tokens + coerced_completion_tokens,
|
||||
prompt_tokens=prompt_tokens,
|
||||
completion_tokens=completion_tokens,
|
||||
total_tokens=prompt_tokens + completion_tokens,
|
||||
cache_creation_input_tokens=cache_creation_input_tokens,
|
||||
cache_read_input_tokens=cache_read_input_tokens,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue