Skip to content

Select existing KB from a drop-down#986

Open
mludvig wants to merge 6 commits into
aws-samples:v3from
mludvig:v3-kb-list
Open

Select existing KB from a drop-down#986
mludvig wants to merge 6 commits into
aws-samples:v3from
mludvig:v3-kb-list

Conversation

@mludvig

@mludvig mludvig commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Replaces the text input for selecting existing Knowledge Base ID in a Bot creation page with a dropdown select that lists all available knowledge bases in the AWS account.

Description of changes:

Backend changes:

  • Add list_knowledge_bases() function to repository layer using Bedrock Agent API pagination
  • Add GET /knowledge-bases endpoint to bot routes

Frontend changes:

  • Import useKnowledgeBaseApi hook to fetch available knowledge bases
  • Replace InputText with Select component for KB selection
  • Show error message when no knowledge bases are found
  • Add i18n translations for 'no knowledge bases found' message (en/ja)

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

Replaces the text input for existing Knowledge Base ID with a dropdown
select that lists all available knowledge bases in the AWS account.

Backend changes:
- Add list_knowledge_bases() function to repository layer using Bedrock
  Agent API pagination
- Add GET /knowledge-bases endpoint to bot routes

Frontend changes:
- Import useKnowledgeBaseApi hook to fetch available knowledge bases
- Replace InputText with Select component for KB selection
- Show error message when no knowledge bases are found
- Add i18n translations for 'no knowledge bases found' message (en/ja)
Copilot AI review requested due to automatic review settings December 2, 2025 21:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the bot creation UX by replacing a manual text input field with a user-friendly dropdown for selecting existing Knowledge Bases from the AWS account. The change leverages the Bedrock Agent API to list available knowledge bases and present them with their names and IDs.

  • Adds backend API endpoint to fetch knowledge bases from Bedrock Agent
  • Replaces text input with dropdown component for KB selection
  • Improves UX with error messages when no knowledge bases exist

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
backend/app/repositories/knowledge_base.py Implements list_knowledge_bases() function with pagination support to retrieve all knowledge bases from Bedrock Agent API
backend/app/routes/bot.py Adds GET /knowledge-bases endpoint to expose knowledge base listing functionality to frontend
frontend/src/features/knowledgeBase/pages/BotKbEditPage.tsx Replaces InputText with Select dropdown for KB selection, adds empty state handling, and clears KB ID when switching radio options
frontend/src/i18n/en/index.ts Adds English translation for "no knowledge bases found" error message and improves existing label text
frontend/src/i18n/ja/index.ts Adds Japanese translation for "no knowledge bases found" error message

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/app/routes/bot.py
Comment thread backend/app/repositories/knowledge_base.py
Comment thread frontend/src/features/knowledgeBase/pages/BotKbEditPage.tsx
Comment thread backend/app/routes/bot.py Outdated
Comment thread backend/app/repositories/knowledge_base.py
Comment thread frontend/src/features/knowledgeBase/pages/BotKbEditPage.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/hooks/useKnowledgeBaseApi.ts
Comment thread frontend/src/features/knowledgeBase/pages/BotKbEditPage.tsx
Comment thread frontend/src/features/knowledgeBase/pages/BotKbEditPage.tsx Outdated
Comment thread frontend/src/i18n/en/index.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/tests/test_repositories/test_knowledge_base.py Outdated
Comment thread backend/app/repositories/knowledge_base.py Outdated
Comment thread backend/app/routes/bot.py Outdated
Comment thread frontend/src/features/knowledgeBase/pages/BotKbEditPage.tsx
@mludvig

mludvig commented Dec 7, 2025

Copy link
Copy Markdown
Contributor Author

@statefb If you're OK with this functionality I believe it's ready for merge.

@mludvig

mludvig commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@statefb fixed black formatting failure

} from '../types';
import { toCamelCase } from '../../../utils/StringUtils';
import useGlobalConfig from '../../../hooks/useGlobalConfig';
import useKnowledgeBaseApi from '../../../hooks/useKnowledgeBaseApi';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cloud you wrap useKnowledgeBaseAPI with useKnowledgeBase needed to be newly created? Please refer another hooks to understand frontend implementation manner.

).map((kb) => ({
value: kb.knowledgeBaseId,
label: `${kb.name} (${kb.knowledgeBaseId})`,
description: kb.description || kb.status,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

description || status mixes different info types. Remove || and conditionally render description only when it exists. Status display is not necessary.

return (
<div className="mt-3 rounded-lg border border-aws-font-color-light/30 p-4 dark:border-aws-font-color-dark/30">
<InputText
<Select

@statefb statefb Dec 12, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In some usecases, users want to enter ID, title, desc with free text format. frontend/src/components/SearchTextBox.tsx should provide better UX (Fetch KB lists and search with title or description).

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