Skip to content

Commit 6fdf59a

Browse files
committed
Python 3.9 compatibility fixes
1 parent 1c0e77f commit 6fdf59a

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

redisvl/index/index.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,15 @@ def hybrid_search(self, query: HybridQuery, **kwargs) -> List[Dict[str, Any]]:
10501050
results = index.hybrid_search(hybrid_query)
10511051
10521052
"""
1053-
results: HybridResult = self._redis_client.ft(
1054-
self.schema.index.name
1055-
).hybrid_search(
1053+
index = self._redis_client.ft(self.schema.index.name)
1054+
if not hasattr(index, "hybrid_search"):
1055+
# TODO: Clarify correct message - it seems to not be available in Python 3.9
1056+
raise NotImplementedError(
1057+
"Hybrid search is not available in this version of redis-py. "
1058+
"Please upgrade to redis-py >= 7.1.0."
1059+
)
1060+
1061+
results: HybridResult = index.hybrid_search(
10561062
query=query.query,
10571063
combine_method=query.combination_method,
10581064
post_processing=(
@@ -1918,9 +1924,15 @@ async def hybrid_search(
19181924
19191925
"""
19201926
client = await self._get_client()
1921-
results: HybridResult = await client.ft(
1922-
self.schema.index.name
1923-
).hybrid_search(
1927+
index = client.ft(self.schema.index.name)
1928+
if not hasattr(index, "hybrid_search"):
1929+
# TODO: Clarify correct message - it seems to not be available in Python 3.9
1930+
raise NotImplementedError(
1931+
"Hybrid search is not available in this version of redis-py. "
1932+
"Please upgrade to redis-py >= 7.1.0."
1933+
)
1934+
1935+
results: HybridResult = await index.hybrid_search(
19241936
query=query.query,
19251937
combine_method=query.combination_method,
19261938
post_processing=(

redisvl/query/hybrid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def __init__(
162162

163163
def build_base_query(
164164
text_query: str,
165-
vector: bytes | List[float],
165+
vector: Union[bytes, List[float]],
166166
vector_field_name: str,
167167
text_scorer: str = "BM25STD",
168168
yield_text_score_as: Optional[str] = None,

0 commit comments

Comments
 (0)