feat: Add hybrid search support for Bedrock KB#1044
Merged
Conversation
… to RepositoryService
…overrideSearchType
3ad42d9 to
f457e17
Compare
There was a problem hiding this comment.
Pull request overview
Adds hybrid (vector + keyword) retrieval for Bedrock Knowledge Base (KB) repositories and propagates a search_mode selection end-to-end (SDK → Lambda → repository service → UI), including UI affordances to show when hybrid was used vs vector fallback.
Changes:
- Backend: introduce
supports_hybrid_search()/hybrid_retrieve()onRepositoryService, implement Bedrock KB hybrid retrieval with targeted fallback, and route requests viasearchModein the repository Lambda. - SDK + API consumers: extend
similarity_search()to acceptsearch_modeand return a structured{ docs, metadata }response. - Frontend: capability-gated “RAG Search Mode” selector, request propagation, and citations header badge indicating Hybrid vs Vector(fallback), plus persistence + tests.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/sdk/test_sdk_rag.py | Updates SDK RAG tests for new similarity_search() return shape; adds search_mode/metadata tests. |
| test/sdk/test_evaluation_runner.py | Adjusts evaluation runner tests to the new { docs: [...] } return format. |
| test/lambda/test_session_lambda.py | Adds round-trip persistence tests for supportsHybridSearch and ragSearchMode. |
| test/lambda/test_repository_lambda.py | Adds tests for repo listing capability flag and searchMode routing/metadata behavior. |
| test/lambda/repository/services/test_repository_service.py | Tests default hybrid-support behavior in the base repository service. |
| test/lambda/repository/services/test_bedrock_kb_repository_service.py | Adds Bedrock KB hybrid retrieve tests, including fallback + error propagation. |
| test/integration/rag/test_rag_collections_integration.py | Updates integration test to consume results["docs"]. |
| lisa-sdk/lisapy/rag.py | SDK adds search_mode / include_score and returns structured response with optional metadata. |
| lisa-sdk/lisapy/evaluation/lisa_api.py | Updates evaluator to read from results["docs"]. |
| lib/user-interface/react/src/shared/reducers/rag.reducer.ts | Adds searchMode param, changes relevant-docs response type, always requests scores. |
| lib/user-interface/react/src/shared/reducers/rag.reducer.test.ts | Tests query builder URL composition for searchMode and score=true. |
| lib/user-interface/react/src/shared/model/configuration.model.ts | Introduces enabledComponents.hybridSearch flag. |
| lib/user-interface/react/src/shared/model/configuration.model.test.ts | Tests defaulting/acceptance for hybridSearch. |
| lib/user-interface/react/src/shared/model/chat.configurations.model.ts | Adds ragSearchMode to session configuration defaults. |
| lib/user-interface/react/src/shared/model/chat.configurations.model.test.ts | Tests ragSearchMode default is vector. |
| lib/user-interface/react/src/components/types.tsx | Adds RagSearchMetadata and typed citation shape. |
| lib/user-interface/react/src/components/Topbar.test.tsx | Refactors menu interaction helper for JSDOM/Cloudscape rendering behavior. |
| lib/user-interface/react/src/components/configuration/ActivatedUserComponents.tsx | Adds “Hybrid search” as an activated component label. |
| lib/user-interface/react/src/components/chatbot/utils/messageBuilder.utils.tsx | Structures citations with similarity score; extracts ragSearchMetadata. |
| lib/user-interface/react/src/components/chatbot/utils/messageBuilder.utils.test.tsx | Tests citation structuring and metadata extraction behavior. |
| lib/user-interface/react/src/components/chatbot/components/SessionConfiguration.tsx | Adds capability-gated “RAG Search Mode” selector. |
| lib/user-interface/react/src/components/chatbot/components/SessionConfiguration.test.tsx | Tests showing/hiding the selector based on flags and repo capability. |
| lib/user-interface/react/src/components/chatbot/components/RagOptions.tsx | Plumbs supportsHybridSearch from repo list into ragConfig. |
| lib/user-interface/react/src/components/chatbot/components/Message.tsx | Adds Hybrid / Vector(fallback) badge in citations header. |
| lib/user-interface/react/src/components/chatbot/Chat.tsx | Sends searchMode in relevant-docs request; warns when hybrid falls back. |
| lib/chat/api/configuration.ts | Enables hybridSearch component flag when RAG is deployed. |
| lambda/shared/python/lisa/session/models.py | Adds ragSearchMode and supportsHybridSearch to session models. |
| lambda/shared/python/lisa/rag/services/repository_service.py | Adds base supports_hybrid_search() and hybrid_retrieve() API. |
| lambda/shared/python/lisa/rag/services/bedrock_kb_repository_service.py | Implements Bedrock KB hybrid retrieve with narrowed ValidationException fallback. |
| lambda/handlers/repository/lambda_functions.py | Adds supportsHybridSearch to repo listing; routes similarity search by searchMode and returns search metadata. |
| .pre-commit-config.yaml | Extends detect-secrets exclude patterns to include .test.ts. |
Comments suppressed due to low confidence (1)
lisa-sdk/lisapy/rag.py:214
paramssetsrepositoryTypetorepo_id, but this query param is not used by the backend similaritySearch handler and the value is not actually a repository type. Sending an incorrect/unused parameter is confusing and could break if server-side validation is added later; consider removing it (or renaming/setting it correctly if needed).
url = f"{self.url}/repository/{repo_id}/similaritySearch"
params: dict[str, str | int] = {"query": query, "repositoryType": repo_id, "topK": k}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
estohlmann
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add hybrid search (vector + keyword) for Bedrock Knowledge Base repositories. When an admin enables hybrid search and a repository supports it, sessions default to hybrid mode. The feature includes automatic fallback to vector-only for unsupported knowledge bases.
Key behaviors:
Breaking change (SDK)
lisapy.RagMixin.similarity_search()now returnsdictinstead oflist[dict]:Test plan
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.