From a36c652b417dc963d29e9ea52b95e64ca0b2a21e Mon Sep 17 00:00:00 2001 From: Anish Gurjar <50738829+anishgurjar@users.noreply.github.com> Date: Mon, 28 Sep 2026 11:37:03 -0400 Subject: [PATCH] Fix ValkeySemanticCache import for redis-py >= 5 --- litellm/caching/valkey_semantic_cache.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/caching/valkey_semantic_cache.py b/litellm/caching/valkey_semantic_cache.py index 58b76d98d6d..a6552a97ce8 100644 --- a/litellm/caching/valkey_semantic_cache.py +++ b/litellm/caching/valkey_semantic_cache.py @@ -24,7 +24,11 @@ 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: + from redis.commands.search.index_definition import IndexDefinition, IndexType +except ModuleNotFoundError: + from redis.commands.search.indexDefinition import IndexDefinition, IndexType from redis.commands.search.query import Query from litellm._logging import print_verbose