Python: Fix RedisContextProvider for redisvl 0.14.0 HybridQuery API change#3954
Python: Fix RedisContextProvider for redisvl 0.14.0 HybridQuery API change#3954
Conversation
…0 compatibility Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
…ment Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a compatibility issue with redisvl 0.14.0, which renamed the HybridQuery constructor parameter from alpha to linear_alpha. The change prevents a TypeError when Redis hybrid search is used with a vectorizer configured.
Changes:
- Updated
RedisContextProvider._redis_search()to passlinear_alphainstead ofalphatoHybridQuery - Added regression test to verify the correct parameter name is used
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/packages/redis/agent_framework_redis/_context_provider.py |
Changed parameter name from alpha to linear_alpha in HybridQuery instantiation (line 376) |
python/packages/redis/tests/test_providers.py |
Added test class TestRedisContextProviderHybridQuery with test verifying linear_alpha parameter usage |
|
Hey there! I'm with the team at Redis that maintains RedisVL - since redisvl==0.13.0 there have been a couple of options for hybrid search, which is where the bug here originally stemmed from. The integration imports and uses the with and associated usages. The syntax that this integration currently expects is the syntax for Switching the Thanks for taking on the fix for this integration! Let me know if that context is helpful or if I can clarify anything. |
| text_scorer=text_scorer, | ||
| filter_expression=combined_filter, | ||
| alpha=alpha, | ||
| linear_alpha=alpha, |
There was a problem hiding this comment.
This is a misleading fix - see my comment on the main PR. As of redisvl>=0.13.0, the HybridQuery class wraps the native Redis FT.HYBRID search command. For this command, alpha refers to the weight of the text query in the score combination.
Prior to redisvl==0.13.0, the implementation used the FT.AGGREGATE operation, and RedisVL defined alpha as the weight of the vector query in the score combination. This legacy approach is still accessible via from redisvl.query import AggregateHybridQuery, which is what the syntax in this project is expecting.
Without care, simply switching alpha to linear_alpha would actually invert the weighting of the score components for existing implementations.
Motivation and Context
redisvl 0.14.0 renamed the
HybridQueryconstructor parameteralphatolinear_alpha, breaking Redis hybrid search with:Description
Core Fix
RedisContextProvider._redis_search()to passlinear_alphainstead ofalphatoHybridQueryTesting
The change is isolated to one parameter name in the HybridQuery instantiation:
Contribution Checklist
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
astral.sh/usr/bin/curl curl -LsSf REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.