diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.py index ad25117943b..0ed2af1e35c 100644 --- a/litellm/completion_extras/litellm_responses_transformation/transformation.py +++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py @@ -1114,14 +1114,13 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): elif isinstance(item, dict): # Handle multimodal content original_type = item.get("type") + content_item = cast( # cast-ok: isinstance confirms the content block is a mapping + dict[str, object], item + ) if original_type == "text": converted = with_prompt_cache_breakpoint( self._convert_content_str_to_input_text(item.get("text", ""), role), - cast( - dict[str, object], item - ).get( # cast-ok: isinstance confirms the content block is a mapping - "prompt_cache_breakpoint" - ), + content_item.get("prompt_cache_breakpoint"), ) result.append(converted) verbose_logger.debug("Chat provider: text -> %s", converted) @@ -1134,11 +1133,7 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): role, ) ), - cast( - dict[str, object], item - ).get( # cast-ok: isinstance confirms the content block is a mapping - "prompt_cache_breakpoint" - ), + content_item.get("prompt_cache_breakpoint"), ) result.append(converted) verbose_logger.debug("Chat provider: image_url -> %s", converted) @@ -1154,11 +1149,7 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge): _input_file_from_file_value( cast("ChatCompletionFileObject", item).get("file"), # cast-ok: type tag checked ), - cast( - dict[str, object], item - ).get( # cast-ok: isinstance confirms the content block is a mapping - "prompt_cache_breakpoint" - ), + content_item.get("prompt_cache_breakpoint"), ) result.append(converted) verbose_logger.debug("Chat provider: file -> %s", converted)