From 60da357c1638012279a263f6926c3a90bcc57647 Mon Sep 17 00:00:00 2001 From: Kannan Priyadharshan Date: Tue, 23 Jun 2026 19:25:58 +0800 Subject: [PATCH] style(anthropic): format messages cache usage helper --- .../adapters/transformation.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index 961d0be672e..fa99aa1bac3 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -1410,7 +1410,7 @@ class LiteLLMAnthropicMessagesAdapter: @classmethod def _first_positive_usage_value( - cls, usage: Usage, field_names: Tuple[str, ...] + cls, usage: Usage, field_names: tuple[str, ...] ) -> int: for field_name in field_names: value = cls._positive_int(getattr(usage, field_name, None)) @@ -1420,7 +1420,7 @@ class LiteLLMAnthropicMessagesAdapter: @classmethod def _first_positive_prompt_tokens_detail_value( - cls, usage: Usage, field_names: Tuple[str, ...] + cls, usage: Usage, field_names: tuple[str, ...] ) -> int: prompt_tokens_details = getattr(usage, "prompt_tokens_details", None) if prompt_tokens_details is None: @@ -1444,9 +1444,7 @@ class LiteLLMAnthropicMessagesAdapter: ) if explicit_value > 0: return explicit_value - return cls._first_positive_prompt_tokens_detail_value( - usage, ("cached_tokens",) - ) + return cls._first_positive_prompt_tokens_detail_value(usage, ("cached_tokens",)) @classmethod def _get_cache_creation_input_tokens(cls, usage: Usage) -> int: @@ -1483,9 +1481,7 @@ class LiteLLMAnthropicMessagesAdapter: return usage_delta @classmethod - def _translate_openai_usage_to_anthropic_usage( - cls, usage: Usage - ) -> AnthropicUsage: + def _translate_openai_usage_to_anthropic_usage(cls, usage: Usage) -> AnthropicUsage: return cast( AnthropicUsage, cls._translate_openai_usage_to_anthropic_usage_delta(usage),