mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
Normalize Realtime usage dict keys before ResponseAPIUsage transform
This commit is contained in:
parent
fa81017e12
commit
ee679dfab0
1 changed files with 16 additions and 0 deletions
|
|
@ -914,6 +914,22 @@ class ResponseAPILoggingUtils:
|
|||
)
|
||||
response_api_usage: ResponseAPIUsage
|
||||
if isinstance(usage_input, dict):
|
||||
# Realtime uses input_token_details and output_token_details; convert to
|
||||
# input_tokens_details and output_tokens_details when those are unset.
|
||||
if (
|
||||
usage_input.get("input_tokens_details") is None
|
||||
and "input_token_details" in usage_input
|
||||
):
|
||||
usage_input["input_tokens_details"] = usage_input[
|
||||
"input_token_details"
|
||||
]
|
||||
if (
|
||||
usage_input.get("output_tokens_details") is None
|
||||
and "output_token_details" in usage_input
|
||||
):
|
||||
usage_input["output_tokens_details"] = usage_input[
|
||||
"output_token_details"
|
||||
]
|
||||
total_tokens = usage_input.get("total_tokens")
|
||||
if total_tokens is None:
|
||||
input_tokens = usage_input.get("input_tokens")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue