fix(caching): expose the shared call type matcher

Signed-off-by: Yusuf Efe <120668197+yuefdev@users.noreply.github.com>
This commit is contained in:
Yusuf Efe 2026-10-18 15:01:05 +03:00
parent 4e1a07cc7a
commit 900b222f83
2 changed files with 4 additions and 4 deletions

View file

@ -94,7 +94,7 @@ def _request_message_count(kwargs: Mapping[str, object]) -> int:
return sum(1 for item in items if _is_conversation_item(item))
def _is_cache_call_type_supported(call_type: str, supported_call_types: Sequence[str] | None) -> bool:
def is_cache_call_type_supported(call_type: str, supported_call_types: Sequence[str] | None) -> bool:
if supported_call_types is None:
return True
normalised_call_type: Final = call_type.lstrip("_")
@ -994,7 +994,7 @@ class Cache:
if raw_source is not None:
raw_name: Final[object] = getattr(raw_source, "value", None) or getattr(raw_source, "__name__", None)
call_type_name: Final = raw_name if isinstance(raw_name, str) else str(raw_source)
if not _is_cache_call_type_supported(call_type_name, self.supported_call_types):
if not is_cache_call_type_supported(call_type_name, self.supported_call_types):
return False
if self.max_messages is not None and _request_message_count(kwargs) > self.max_messages:
return False

View file

@ -27,7 +27,7 @@ import litellm
from litellm._internal_context import is_internal_call, post_response_phase
from litellm._logging import print_verbose, verbose_logger
from litellm.caching import InMemoryCache
from litellm.caching.caching import S3Cache, _is_cache_call_type_supported, response_cache_phase
from litellm.caching.caching import S3Cache, is_cache_call_type_supported, response_cache_phase
from litellm.constants import CACHE_WRITE_SHUTDOWN_FLUSH_TIMEOUT_SECONDS, RESPONSE_CACHE_EXCLUDED_PROVIDERS
from litellm.litellm_core_utils.hidden_params import get_hidden_params
from litellm.litellm_core_utils.llm_response_utils.response_metadata import (
@ -1292,7 +1292,7 @@ class LLMCachingHandler:
"""
if litellm.cache is None:
return False
return _is_cache_call_type_supported(original_function.__name__, litellm.cache.supported_call_types)
return is_cache_call_type_supported(original_function.__name__, litellm.cache.supported_call_types)
async def add_streaming_response_to_cache(self, processed_chunk: ModelResponse) -> None:
"""