Python: Fix RedisContextProvider for redisvl 0.14.0 by using AggregateHybridQuery#3954
Python: Fix RedisContextProvider for redisvl 0.14.0 by using AggregateHybridQuery#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.
|
@copilot please review @vishal-bala comments and adjust accordingly. @vishal-bala many thanks for jumping in here! |
I don't see any comments from @vishal-bala in the current thread. Could you please share or point me to the specific feedback that needs to be addressed? |
|
@copilot this one #3954 (comment) and #3954 (comment) |
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Added CHANGELOG entry for the fix in commit 192e1ac. |
|
@copilot Here is the gist of my recommended changes: The integration imports and uses the with and to update its usages accordingly. |
|
@eavanvalkenburg Happy to help! It looks like Copilot doesn't see or respond to my comments - feel free to copy-paste or paraphrase them if you need to instruct Copilot to take action 😄 |
@copilot Implement and test this recommended changes |
…ility Replace HybridQuery with AggregateHybridQuery to preserve existing functionality that works with older Redis versions. The new HybridQuery in redisvl 0.14.0 requires Redis 8.4.0+ and uses a different API, while AggregateHybridQuery maintains compatibility with the original implementation. Co-authored-by: TaoChenOSU <12570346+TaoChenOSU@users.noreply.github.com>
Implemented the recommended changes in commit 9c6ad7c. Replaced |
Motivation and Context
redisvl 0.14.0 introduced a breaking change where
HybridQuerywas replaced with a new implementation requiring Redis 8.4.0+. The original code usedHybridQuery, which caused compatibility issues:Description
Core Fix
HybridQuerywithAggregateHybridQueryinRedisContextProvider._redis_search()to maintain backward compatibility with older Redis versionsAggregateHybridQuerypreserves the original aggregation pipeline-based hybrid search functionality that works with Redis versions prior to 8.4.0alphaparameter as expected byAggregateHybridQueryWhy AggregateHybridQuery instead of the new HybridQuery?
HybridQueryin redisvl 0.14.0+ uses Redis's nativeFT.HYBRIDcommand, which requires Redis 8.4.0+AggregateHybridQueryuses the aggregation pipeline approach, maintaining compatibility with existing Redis deploymentsTesting
AggregateHybridQueryis used with the correctalphaparameterDocumentation
The change replaces the query class and maintains the original parameter:
Contribution Checklist
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.