Skip to content

feat: Add hybrid search support for Bedrock KB#1044

Merged
estohlmann merged 19 commits into
developfrom
feat/bedrock-kb-hybrid
May 28, 2026
Merged

feat: Add hybrid search support for Bedrock KB#1044
estohlmann merged 19 commits into
developfrom
feat/bedrock-kb-hybrid

Conversation

@gingerknight
Copy link
Copy Markdown
Contributor

@gingerknight gingerknight commented May 22, 2026

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:

  • Admin toggle acts as a hard gate — disabling forces all sessions to vector regardless of user selection
  • UI shows a search mode selector only when the repository supports hybrid
  • Citations display which search mode was actually used (Hybrid vs Vector fallback)
  • Chat Assistant stacks correctly activate hybrid when their configured repository supports it

Breaking change (SDK)

lisapy.RagMixin.similarity_search() now returns dict instead of list[dict]:

  # Before
  docs = client.similarity_search(query, repository_id, top_k=3)

  # After
  result = client.similarity_search(query, repository_id, top_k=3)
  docs = result["docs"]
  metadata = result["metadata"]  # search_mode, actual_mode_used, backend, hybrid_supported

Test plan

  • Unit tests pass: npm run test:lambda, frontend npm test
  • Deployed to dev account and verified hybrid badge displays correctly
  • Session save/load preserves hybrid search mode selection
  • Chat Assistant stack shows hybrid selection dropdown
Screenshot 2026-05-22 at 11 24 22

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() on RepositoryService, implement Bedrock KB hybrid retrieval with targeted fallback, and route requests via searchMode in the repository Lambda.
  • SDK + API consumers: extend similarity_search() to accept search_mode and 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

  • params sets repositoryType to repo_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.

Comment thread lisa-sdk/lisapy/rag.py
Comment thread lisa-sdk/lisapy/rag.py
Comment thread lambda/handlers/repository/lambda_functions.py Outdated
Comment thread test/sdk/test_sdk_rag.py Outdated
Comment thread lambda/handlers/repository/lambda_functions.py
@gingerknight gingerknight marked this pull request as ready for review May 26, 2026 17:23
@gingerknight gingerknight marked this pull request as draft May 26, 2026 18:24
@gingerknight gingerknight marked this pull request as ready for review May 27, 2026 19:37
@estohlmann estohlmann merged commit bdc23f2 into develop May 28, 2026
8 checks passed
@estohlmann estohlmann deleted the feat/bedrock-kb-hybrid branch May 28, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants