Skip to content

AdhiJarwal/RAG_Chatbot

Repository files navigation

AWS Bedrock RAG Chatbot

Complete implementation of a RAG chatbot using AWS Bedrock with OpenSearch for vector storage and Claude for responses.

Architecture

PDF (S3) → Lambda/Script → Bedrock Embeddings → OpenSearch → Bedrock LLM → Response

Setup Instructions

1. Prerequisites

pip install -r requirements.txt

2. Configure Environment

cp .env.example .env
# Run interactive setup to configure your environment
python setup_env.py

3. Setup AWS Resources

python setup_aws_resources.py

4. Upload PDFs to S3

aws s3 cp your-document.pdf s3://your-bucket/pdfs/

Usage

  1. Process PDFs and Create Embeddings:
python pdf_processor.py
  1. Run Interactive Chatbot:
python rag_chatbot.py
  1. Run Web Interface:
streamlit run streamlit_app.py

Key Components

  • pdf_processor.py: Extracts text, chunks documents, generates embeddings
  • opensearch_manager.py: Manages vector storage and similarity search
  • rag_chatbot.py: Main RAG pipeline with Claude integration
  • streamlit_app.py: Web interface
  • setup_aws_resources.py: AWS infrastructure setup

Cost Estimation

  • OpenSearch: ~$50-100/month (t3.small)
  • Bedrock Embeddings: ~$0.0001/1K tokens
  • Bedrock Claude: ~$0.008/1K tokens

Security Best Practices

  1. Use IAM roles with minimal permissions
  2. Enable VPC for OpenSearch
  3. Encrypt data at rest and in transit
  4. Use AWS Secrets Manager for credentials
  5. Enable CloudTrail logging

Troubleshooting

  • OpenSearch connection issues: Check security groups and access policies
  • Bedrock model access: Ensure model access is enabled in Bedrock console
  • Memory issues: Reduce chunk size or batch processing

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages