mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix: restore defensive behavior for unknown usage types
- Restore original defensive behavior: return Usage(0,0,0) for unknown types instead of raising ValueError - Keep explicit ResponseAPIUsage handling to fix the bug where it was incorrectly returning 0 tokens - Maintain backward compatibility by preserving original error handling approach
This commit is contained in:
parent
d5f76a4da4
commit
19c9bb5c17
1 changed files with 7 additions and 2 deletions
|
|
@ -4525,8 +4525,13 @@ class StandardLoggingPayloadSetup:
|
|||
)
|
||||
elif isinstance(usage, dict):
|
||||
return Usage(**usage)
|
||||
|
||||
raise ValueError(f"usage is required, got={usage} of type {type(usage)}")
|
||||
else:
|
||||
# Unknown type - return 0 tokens (defensive behavior)
|
||||
return Usage(
|
||||
prompt_tokens=0,
|
||||
completion_tokens=0,
|
||||
total_tokens=0,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_model_cost_information(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue