mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-29 01:42:19 +00:00
fix: ValkeySemanticCache import compatibility with redis-py >= 5
Fixes #39180 - ValkeySemanticCache crashes at import with redis-py >= 5 due to stale camelCase import of redis.commands.search.indexDefinition. redis-py >= 5 uses snake_case module name (index_definition), while redis-py 4.x uses camelCase (indexDefinition). Add try/except to support both versions.
This commit is contained in:
parent
31ca4ddf32
commit
5bc62d32dc
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue