-
Notifications
You must be signed in to change notification settings - Fork 28
Feat/42 redis search tools #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add RedisVectorSearchTool for KNN semantic search - Add RedisTextSearchTool for BM25 keyword search - Add RedisRangeSearchTool for threshold-based search - Add RedisHybridSearchTool for combined vector + text search - Add redis-vl optional dependency (redisvl, nltk, sentence-transformers) - Add sample agent demonstrating all search tools - Add unit tests for all tools
- Add vector_param_name, yield_text_score_as, vector_search_method - Add knn_ef_runtime, range_radius, range_epsilon, yield_vsim_score_as - Add yield_combined_score_as for score output control - Document Redis >= 8.4.0 and redis-py >= 7.1.0 requirements
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @nkanu17, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the capabilities of the ADK by integrating RedisVL-based search tools. It provides a robust, self-hosted alternative for knowledge base retrieval, offering various search modalities like vector, text, hybrid, and range searches. This enhancement allows agents to interact with Redis-backed knowledge bases, catering to developers who require more control over their infrastructure and complementing existing Google Cloud retrieval options. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a comprehensive set of Redis search tools, enabling vector, text, hybrid, and range searches. The implementation is well-structured, with a base class for vector-based tools, separate handling for text search, and a clever lazy-loading mechanism for the optional dependencies. The accompanying sample agent and documentation are excellent and provide clear guidance for users.
My review includes a critical fix for the sample agent to ensure it runs correctly, along with a few medium-severity suggestions to improve design consistency, reduce code duplication, and refine the lazy-loading implementation for better performance and maintainability. Overall, this is a high-quality contribution that significantly enhances the library's capabilities.
contributing/samples/redis_vl_search/redis_vl_search_agent/agent.py
Outdated
Show resolved
Hide resolved
Address PR google#43 code review feedback from Gemini Code Assist. Update model name from gemini-2.0-flash-001 to gemini-2.5-flash in: - Sample agent (agent.py) - Tool docstrings (vector, text, hybrid, range search tools) - GitHub issue document
- Split BaseRedisSearchTool into shared base + VectorizedSearchTool - BaseRedisSearchTool now contains shared logic (_execute_query, _run_search) - VectorizedSearchTool requires vectorizer (no longer Optional) - RedisTextSearchTool now extends BaseRedisSearchTool (inherits shared logic) - Vector-based tools extend VectorizedSearchTool This addresses PR review feedback: - 2b: Vectorizer is now required in VectorizedSearchTool (fail-fast) - 2c: Eliminates ~14 lines of duplicated code via inheritance
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This is an excellent pull request that adds significant value by providing self-hosted Redis-based retrieval tools as an alternative to cloud-based solutions. The code quality is high, with well-structured, documented, and tested tool classes that thoughtfully expose the underlying redisvl library's capabilities. The use of base classes and lazy loading for optional dependencies is well-executed. I have a couple of minor suggestions to improve performance in the sample data loading script and enhance maintainability in one of the tool classes. Overall, a very strong contribution.
Add configuration classes to group query-specific parameters: - RedisVectorQueryConfig: 15 parameters for vector similarity search - RedisRangeQueryConfig: 11 parameters for range-based search - RedisHybridQueryConfig: 22 parameters for hybrid text+vector search - RedisTextQueryConfig: 8 parameters for full-text search Each config class includes: - Pydantic validation with Field() constraints - ConfigDict(extra='forbid') to catch typos - to_query_kwargs() method for query construction - Comprehensive docstrings for each parameter
Refactor all four Redis search tools to accept config objects: - RedisVectorSearchTool: 22 params -> 7 params - RedisHybridSearchTool: 26 params -> 7 params - RedisRangeSearchTool: 14 params -> 7 params - RedisTextSearchTool: 12 params -> 6 params Benefits: - Reduces constructor parameter explosion - Groups query-specific parameters logically - Follows BigQueryToolConfig and OpenMemoryServiceConfig patterns - Enables Pydantic validation of parameters
Add exports for all Redis config classes: - RedisVectorQueryConfig - RedisHybridQueryConfig - RedisRangeQueryConfig - RedisTextQueryConfig Supports lazy loading pattern for optional redisvl dependency.
Update all Redis search tool tests to use config objects: - test_vector_search_tool.py - test_hybrid_search_tool.py - test_range_search_tool.py - test_text_search_tool.py Tests now verify config object properties instead of direct attributes.
Update sample agent and README to use config objects: - RedisVectorQueryConfig for semantic_search - RedisTextQueryConfig for keyword_search - RedisRangeQueryConfig for range_search README examples updated to show config-based usage pattern.
- Add RedisAggregatedHybridQueryConfig for older RedisVL versions (<0.13.0) - RedisHybridSearchTool now auto-detects RedisVL version and uses appropriate query class - Native HybridQuery (FT.HYBRID) used for RedisVL >= 0.13.0, Redis >= 8.4.0 - AggregateHybridQuery (FT.AGGREGATE) used for older versions - Emit DeprecationWarning when using aggregate config on newer versions - Raise ValueError when using native config on older versions - Use packaging.version.parse() for version comparison (aligns with ADK patterns) - Update tests to cover both code paths and version detection
…hybrid support - Add _MIN_REDIS_SERVER_VERSION constant (8.4.0) for FT.HYBRID command - Add _get_redis_server_version() to retrieve Redis server version from index client - Update _supports_native_hybrid() to check both redisvl >= 0.13.0 AND Redis >= 8.4.0 - Add proper logging: debug for version mismatches, warning for parsing errors - Handle edge cases: None client, connection errors, version parsing failures - Update error messages to include both version numbers - Add comprehensive tests for Redis server version detection
|
@hangfei @koverholt |
Add RedisVL Search Tools for Knowledge Base Retrieval
This PR adds four RedisVL-based search tools as optional dependencies, enabling agents to perform vector, text, hybrid, and range searches against Redis-based knowledge bases. This provides a self-hosted alternative to Google Cloud retrieval tools (Vertex AI Search, Discovery Engine).
Related to issue #42
Changes
New Tools (
src/google/adk_community/tools/redis/)RedisVectorSearchToolRedisTextSearchToolRedisHybridSearchToolRedisRangeSearchToolDependencies (
pyproject.toml)Installation:
Sample Agent
Added
contributing/samples/redis_vl_search/with a complete example demonstrating all four search tools.Requirements for HybridQuery
RedisHybridSearchTooluses Redis's nativeFT.HYBRIDcommand and requires:Related Issues
Testing
Unit Tests
All tests pass with mocked RedisVL dependencies.
Manual E2E Testing
Screenshots using adk web:

Additional Notes
SearchIndexandAsyncSearchIndexBaseToolwith properFunctionDeclarationfor LLM integration