diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.py index 8f874edfddf..0d227f5031f 100644 --- a/litellm/litellm_core_utils/prompt_templates/common_utils.py +++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py @@ -179,15 +179,15 @@ from litellm.litellm_core_utils.prompt_templates.tool_call_json_repair import ( from litellm.litellm_core_utils.prompt_templates.tool_call_json_repair import ( split_concatenated_json_objects as split_concatenated_json_objects, # noqa: PLC0414 # public compatibility re-export ) -from litellm.litellm_core_utils.prompt_templates.tpm_media_utils import ( - _image_part_url, # pyright: ignore[reportPrivateUsage] # Shared implementation for as_openai_image_part -) from litellm.litellm_core_utils.prompt_templates.tpm_media_utils import ( anthropic_image_source_to_openai_url as anthropic_image_source_to_openai_url, # noqa: PLC0414 # public compatibility re-export ) from litellm.litellm_core_utils.prompt_templates.tpm_media_utils import ( embedding_input_is_all_media as embedding_input_is_all_media, # noqa: PLC0414 # public compatibility re-export ) +from litellm.litellm_core_utils.prompt_templates.tpm_media_utils import ( + image_part_url, +) from litellm.litellm_core_utils.prompt_templates.tpm_media_utils import ( split_embedding_media_for_tpm as split_embedding_media_for_tpm, # noqa: PLC0414 # public compatibility re-export ) @@ -537,7 +537,7 @@ def as_openai_image_part(part: Mapping[str, object]) -> ChatCompletionImageObjec Rebuilt rather than forwarded so no caller-controlled key beyond the URL rides along. """ - url: Final = _image_part_url(part) + url: Final = image_part_url(part) return {"type": "image_url", "image_url": {"url": url}} if url else None diff --git a/litellm/litellm_core_utils/prompt_templates/tpm_media_utils.py b/litellm/litellm_core_utils/prompt_templates/tpm_media_utils.py index a4cb52d689c..181c6576909 100644 --- a/litellm/litellm_core_utils/prompt_templates/tpm_media_utils.py +++ b/litellm/litellm_core_utils/prompt_templates/tpm_media_utils.py @@ -83,7 +83,7 @@ def _tpm_media_leaf(value: object) -> _TPMMediaProjection: image: Final = as_str_mapping(part.get("image_url")) source: Final = as_str_mapping(part.get("source")) canonical: Final = _tpm_image_part( - _image_part_url({**part, "type": "input_image"} if kind == "computer_screenshot" else part) or "", + image_part_url({**part, "type": "input_image"} if kind == "computer_screenshot" else part) or "", (image or part).get("detail", part.get("detail", "auto")), ) projected: Final = ( @@ -243,7 +243,7 @@ def anthropic_image_source_to_openai_url(image_source: Mapping[str, object]) -> return None -def _image_part_url(part: Mapping[str, object]) -> str | None: +def image_part_url(part: Mapping[str, object]) -> str | None: """The image URL carried by one content part, whichever of the three dialects wrote it.""" part_type: Final = part.get("type") if part_type in ("image_url", "input_image"): diff --git a/litellm/proxy/common_utils/user_api_key_cache.py b/litellm/proxy/common_utils/user_api_key_cache.py index c7c73cfc2a8..d0eca5749cc 100644 --- a/litellm/proxy/common_utils/user_api_key_cache.py +++ b/litellm/proxy/common_utils/user_api_key_cache.py @@ -289,7 +289,7 @@ class UserApiKeyCache(DualCache): verbose_proxy_logger.error("UserApiKeyCache.async_get_cache failed for key=%r: %s", key, e) return None - def set_cache(self, key: str | None, value: CacheValue, local_only: bool = False, **kwargs: object): + def set_cache(self, key: str | None, value: CacheValue, local_only: bool = False, **kwargs: object) -> None: model_type: Final = cast(type[BaseModel] | None, kwargs.pop("model_type", None)) payload: Final[object] = CacheCodec.serialize(value, model_type=model_type) shared: Final = self._shared @@ -308,7 +308,9 @@ class UserApiKeyCache(DualCache): return self.key_object_cache.set_cache(key=key, value=payload, local_only=local_only, **kwargs) return super().set_cache(key=key, value=payload, local_only=local_only, **kwargs) - async def async_set_cache(self, key: str | None, value: CacheValue, local_only: bool = False, **kwargs: object): + async def async_set_cache( + self, key: str | None, value: CacheValue, local_only: bool = False, **kwargs: object + ) -> None: """Inside a request the Redis SET rides the request's pipeline (memory is written at once); anywhere else, or with options the pipeline does not carry, it goes to Redis directly as before.""" model_type: Final = cast(type[BaseModel] | None, kwargs.pop("model_type", None)) diff --git a/litellm/proxy/hooks/sensitive_data_routing.py b/litellm/proxy/hooks/sensitive_data_routing.py index 29ab902d39a..2822f547ee9 100644 --- a/litellm/proxy/hooks/sensitive_data_routing.py +++ b/litellm/proxy/hooks/sensitive_data_routing.py @@ -41,7 +41,9 @@ class _PROXY_SensitiveDataRoutingHandler(CustomLogger): model field if a routing override exists for the session. """ - def __init__(self, internal_usage_cache: InternalUsageCache, route_pins: SensitiveRoutePinStore | None = None): + def __init__( + self, internal_usage_cache: InternalUsageCache, route_pins: SensitiveRoutePinStore | None = None + ) -> None: self.route_pins: Final = route_pins or SensitiveRoutePinStore( connect(internal_usage_cache.dual_cache.redis_cache).sensitive_route_pins() )