BedrockChat acts as a conversational interface, leveraging generative AI models fine-tuned on your content. This feature provides users with accurate, timely information and expert insights, transforming static content consumption into a dynamic, interactive experience. BedrockChat is powered by AWS Bedrock, AWS Kendra, LangChain and Streamlit for UI.
Potential benefits of BedrockChat include an increase in user numbers and subscriptions for your website, which could lead to an increase in revenue. Furthermore, it could help solidify your position as a trusted information source within the industry.
This AI-driven application offers:
- State-of-the-art Retrieval Augmented Generation (RAG) mechanism designed to mitigate hallucinations and model drifting.
- The ability to reference sources, allowing users to click and access the full content of your website, reinforcing their engagement.
- A modular architecture, allowing for flexibility in swapping the LLM or knowledge base with newer technologies as they become available.
- Ensured data security as you host and deploy your retrieval system and LLM in your account, eliminating the need to send data to a third party.
To set up the application, follow the steps below:
Prerequisites You need to have AWS account with access to AWS Bedrock and AWS Kendra. Create an index in AWS Kendra and using one of the provided connectors (for example, Web crawler), ingest documents into the AWS Kendra index.(Please note that AWS Kendra and AWS Bedrock are NOT part of AWS free tier and you will be charged)
- Clone the repository:
git clone https://github.com/iut62elec/BedrockChat.git
- Navigate into the project directory:
cd BedrockChat
- Create and activate a virtual environment:
python3.8 -m venv .venv source .venv/bin/activate
- Upgrade pip and install the required dependencies:
pip install --upgrade pip pip install boto3==1.26.163 pip install watchdog pip install streamlit pip install langchain pip install streamlit-cognito-auth python -m pip install ./whl_files/botocore-1.29.162-py3-none-any.whl python -m pip install ./whl_files/boto3-1.26.162-py3-none-any.whl python -m pip install ./whl_files/awscli-1.27.162-py3-none-any.whl
- Deactivate and reactivate the virtual environment with AWS credentials (Remember to replace "AWS_PROFILE_WITH_Bedrock_KENDRA_access" and "XXXXX" with your actual AWS profile and Kendra index ID):
deactivate export AWS_PROFILE=AWS_PROFILE_WITH_Bedrock_KENDRA_access export AWS_REGION="us-east-1" export KENDRA_INDEX_ID_BR="XXXXX" source .venv/bin/activate
- Navigate into the source code and run the application:
cd ./src streamlit run app_BedrockChat.py bedrock
This will open a local server at http://localhost:8501/, where you can start interacting with the AI!
This repository represents my viewpoints and not those of my past or current employers, including Amazon Web Services (AWS). All third-party libraries, modules, plugins, SDKs, product names, logos, and brands are the property of their respective owners. This code acts as a sample to use AWS Bedrock for Chatbot and has been tested on a Mac device and works well, but use at your own caution. This software or code is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. It is intended to serve as a sample or pseudocode for a Proof of Concept (POC) only. In no event shall the authors be liable for any claim, damages, or other liability, whether in an action of contract, tort or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. Please note that your use of this code constitutes acceptance of this statement.