From ab70d0c338aee5748afc9d5003f84adaeae439bd Mon Sep 17 00:00:00 2001 From: michelligabriele Date: Mon, 30 Mar 2026 20:23:47 +0200 Subject: [PATCH] style: apply Black formatting to caching files --- litellm/caching/caching.py | 9 ++++----- litellm/caching/caching_handler.py | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/litellm/caching/caching.py b/litellm/caching/caching.py index 97e5fa330cb..c32e2091d9c 100644 --- a/litellm/caching/caching.py +++ b/litellm/caching/caching.py @@ -698,10 +698,7 @@ class Cache: For multi-item responses, distributes integer fields evenly across items so that summing all per-item details reconstructs the original totals. """ - if ( - result.usage is None - or result.usage.prompt_tokens_details is None - ): + if result.usage is None or result.usage.prompt_tokens_details is None: return None details = result.usage.prompt_tokens_details @@ -751,7 +748,9 @@ class Cache: # Always convert to properly typed CachedEmbedding model_name = result.model embedding_dict: CachedEmbedding = self._convert_to_cached_embedding( - embedding_response, model_name, prompt_tokens_details=prompt_tokens_details, + embedding_response, + model_name, + prompt_tokens_details=prompt_tokens_details, ) cache_key, cached_data, kwargs = self._add_cache_logic( diff --git a/litellm/caching/caching_handler.py b/litellm/caching/caching_handler.py index ab292bc6f33..4b6dc8d009d 100644 --- a/litellm/caching/caching_handler.py +++ b/litellm/caching/caching_handler.py @@ -79,7 +79,9 @@ class CachingHandlerResponse(BaseModel): cached_result: Optional[Any] = None final_embedding_cached_response: Optional[EmbeddingResponse] = None - embedding_all_elements_cache_hit: bool = False # this is set to True when all elements in the list have a cache hit in the embedding cache, if true return the final_embedding_cached_response no need to make an API call + embedding_all_elements_cache_hit: bool = ( + False # this is set to True when all elements in the list have a cache hit in the embedding cache, if true return the final_embedding_cached_response no need to make an API call + ) in_memory_cache_obj = InMemoryCache() @@ -447,9 +449,7 @@ class LLMCachingHandler: ## USAGE prompt_tokens_details: Optional[PromptTokensDetailsWrapper] = None if aggregated_details: - prompt_tokens_details = PromptTokensDetailsWrapper( - **aggregated_details - ) + prompt_tokens_details = PromptTokensDetailsWrapper(**aggregated_details) usage = Usage( prompt_tokens=prompt_tokens, completion_tokens=0, @@ -1078,9 +1078,9 @@ class LLMCachingHandler: } if litellm.cache is not None: - litellm_params[ - "preset_cache_key" - ] = litellm.cache._get_preset_cache_key_from_kwargs(**kwargs) + litellm_params["preset_cache_key"] = ( + litellm.cache._get_preset_cache_key_from_kwargs(**kwargs) + ) else: litellm_params["preset_cache_key"] = None