diff --git a/litellm/caching/valkey_semantic_cache.py b/litellm/caching/valkey_semantic_cache.py index 58b76d98d6d..4f6e1b9564f 100644 --- a/litellm/caching/valkey_semantic_cache.py +++ b/litellm/caching/valkey_semantic_cache.py @@ -24,7 +24,10 @@ from typing import Any, Final from redis import Redis from redis.asyncio import Redis as AsyncRedis from redis.commands.search.field import TagField, VectorField -from redis.commands.search.indexDefinition import IndexDefinition, IndexType +try: # redis-py >= 5 (module renamed to snake_case) + from redis.commands.search.index_definition import IndexDefinition, IndexType +except ModuleNotFoundError: # redis-py 4.x (last version with camelCase name) + from redis.commands.search.indexDefinition import IndexDefinition, IndexType from redis.commands.search.query import Query from litellm._logging import print_verbose