mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
fix(streaming): drop zero usage.cost in calculate_total_usage
Greptile P1: Vertex stream chunks can leave usage.cost=0 on assembled usage; stamping that value bypasses token-based stream spend. Reuse _resolve_provider_reported_cost so non-positive leftovers are omitted.
This commit is contained in:
parent
fd855b2b57
commit
8567010897
1 changed files with 3 additions and 2 deletions
|
|
@ -2604,8 +2604,9 @@ def calculate_total_usage(chunks: list[ModelResponse]) -> Usage:
|
|||
if isinstance(latest_usage_chunk, dict)
|
||||
else getattr(latest_usage_chunk, "cost", None)
|
||||
)
|
||||
if latest_cost is not None:
|
||||
returned_usage_chunk.cost = latest_cost
|
||||
resolved_cost: Final = CustomStreamWrapper._resolve_provider_reported_cost(latest_cost)
|
||||
if resolved_cost is not None:
|
||||
returned_usage_chunk.cost = resolved_cost
|
||||
|
||||
return returned_usage_chunk
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue