style(vertex_ai): format cost calculator

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Devin AI 2026-09-23 02:13:24 +00:00
parent bcb6a69886
commit a15b681ba2

View file

@ -184,9 +184,7 @@ def _handle_128k_pricing(
output_cost_per_token_above_128k_tokens = model_info.get("output_cost_per_token_above_128k_tokens")
prompt_tokens_details: Final = usage.prompt_tokens_details
cache_read_tokens: Final = (
(prompt_tokens_details.cached_tokens or 0) if prompt_tokens_details is not None else 0
)
cache_read_tokens: Final = (prompt_tokens_details.cached_tokens or 0) if prompt_tokens_details is not None else 0
cache_creation_tokens: Final = (
(prompt_tokens_details.cache_creation_tokens or 0) if prompt_tokens_details is not None else 0
)
@ -203,9 +201,7 @@ def _handle_128k_pricing(
cache_creation_rate: Final = model_info.get("cache_creation_input_token_cost") or input_rate
prompt_cost = (
text_tokens * input_rate
+ cache_read_tokens * cache_read_rate
+ cache_creation_tokens * cache_creation_rate
text_tokens * input_rate + cache_read_tokens * cache_read_rate + cache_creation_tokens * cache_creation_rate
)
## CALCULATE OUTPUT COST