mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
Fix audio cost calculation
This commit is contained in:
parent
4b6a0c2356
commit
7225ce5b7d
1 changed files with 9 additions and 7 deletions
|
|
@ -2226,18 +2226,20 @@ class BaseTokenUsageProcessor:
|
|||
CompletionTokensDetailsWrapper()
|
||||
)
|
||||
|
||||
# Check what keys exist in the model's completion_tokens_details
|
||||
# Access model_fields on the class, not the instance, to avoid Pydantic 2.11+ deprecation warnings
|
||||
for attr in type(usage.completion_tokens_details).model_fields:
|
||||
if not attr.startswith("_") and not callable(
|
||||
getattr(usage.completion_tokens_details, attr)
|
||||
):
|
||||
current_val = getattr(
|
||||
combined.completion_tokens_details, attr, 0
|
||||
current_val = (
|
||||
getattr(combined.completion_tokens_details, attr, 0)
|
||||
or 0
|
||||
)
|
||||
new_val = getattr(usage.completion_tokens_details, attr, 0)
|
||||
|
||||
if new_val is not None and current_val is not None:
|
||||
new_val = (
|
||||
getattr(usage.completion_tokens_details, attr, 0) or 0
|
||||
)
|
||||
if new_val is not None and isinstance(
|
||||
new_val, (int, float)
|
||||
):
|
||||
setattr(
|
||||
combined.completion_tokens_details,
|
||||
attr,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue