Select existing KB from a drop-down#986
Conversation
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@statefb If you're OK with this functionality I believe it's ready for merge. |
|
@statefb fixed black formatting failure |
| } from '../types'; | ||
| import { toCamelCase } from '../../../utils/StringUtils'; | ||
| import useGlobalConfig from '../../../hooks/useGlobalConfig'; | ||
| import useKnowledgeBaseApi from '../../../hooks/useKnowledgeBaseApi'; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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).
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:
Frontend changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.