A simple web application that provides Generative AI chat functionality using Amazon Bedrock with Retrieval-Augmented Generation (RAG) capabilities through Bedrock Knowledge Base.
This project implements a conversational AI interface that can retrieve information from a knowledge base to provide more accurate and contextual responses. The application consists of:
- Frontend: Web interface hosted on AWS Amplify using ReactJS
- Backend: API Gateway and Lambda function (Python)
- AI Services: Amazon Bedrock for FM access and Knowledge Base for RAG capabilities
- Vector Database: Amazon OpenSearch Serverless
- Data Source: Amazon S3 for data source storage
claude-chat-app/
├── amplify/ # AWS Amplify configuration and backend code
│ └── backend/
│ └── function/ # Lambda function code
│ └──bedrockRagFunction/src/index.py # Edit the knowledge base ID in this file
├── prerequisites/
│ ├── data/ # Local data source file for knowledge base
│ ├── create_bedrock_kb.py # Script to create Bedrock Knowledge Base
│ ├── requirements.txt # Python modules needed
│ └── README.md # Instructions for the prerequisites
├── src/
│ ├── App.js # Main application component
│ ├── App.css # Application styles
│ └── index.js # Application entry point
├── package.json # NPM dependencies
└── README.md # Project documentation (this README file)
# Clone this repository
git clone https://github.com/MardiantoS/chat-ai-bedrock-rag.git
# Navigate to the project directory
cd chat-ai-bedrock-rag
- AWS Account with appropriate permissions
- AWS CLI configured with access and secret keys
- AWS Amplify package
- Python 3.9 or higher
- Node.js and npm (for the frontend)
Before deploying the main application, you need to set up the Knowledge Base:
- Navigate to the
prerequisites
directory - Follow the README instructions within the directory
- Note the Knowledge Base ID that is generated from the script
- Edit
amplify/backend/function/bedrockRagFunction/src/index.py
and update the Knowledge Based ID placeholder with the one generated in the previous step
- Install Amplify CLI if you haven't already
npm install -g @aws-amplify/cli
- Install dependency packages:
npm install
- Deploy the backend services:
amplify push
- Run the app in the development mode.
npm start
- Open http://localhost:3000 to view it in your browser.
Once your local test is successful, you can deploy the frontend. If you're running it for the first, run
-
Add hosting to your Amplify project:
amplify add hosting
-
Choose your hosting options:
? Select the plugin module to execute: Hosting with Amplify Console ? Choose a type: Manual deployment
-
Deploy your application:
amplify publish
- Navigate to the deployed Amplify URL in your web browser
- Start a conversation in the chat interface
- You can ask questions about JPMorgan Cahse shareholder and financial highlight reports for 2023 and 2024, and the application will use Retrieval-Augmented Generation (RAG) capability from the Amazon Bedrock Knowledge Base to provide more accurate and contextual responses
Here are some example questions you can ask:
- "What was net income per share in 2022, 2023, and 2024?"
- "What are the significant challenges in 2024?"
- "When did Jamie Dimon start as CEO of BankOne?"
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this code in your projects or research, please include the following citation:
Mardianto Hadiputro. (2025). AI Chat Application with Amazon Bedrock RAG. GitHub. https://github.com/MardiantoS/chat-ai-bedrock-rag
- The prerequisite script is based on the RAG examples from Amazon Bedrock Workshop | Knowledge Bases and RAG