An end-to-end medical assistant chatbot built using LLMs, LangChain, Pinecone, and Flask. It can answer health-related questions using vector-based semantic retrieval and GPT-powered reasoning. (This project is for educational purposes and does not provide medical advice.)
git clone https://github.com/entbappy/Build-a-Complete-Medical-Chatbot-with-LLMs-LangChain-Pinecone-Flask-AWS.git
cd Build-a-Complete-Medical-Chatbot-with-LLMs-LangChain-Pinecone-Flask-AWSconda create -n medibot python=3.10 -y
conda activate medibotpip install -r requirements.txtIn the root folder, create a .env file:
PINECONE_API_KEY=your_pinecone_api_key
OPENAI_API_KEY=your_openai_api_key
python store_index.pypython app.pyThen open your browser and go to:
http://127.0.0.1:8080
You’ll see the chatbot interface (from templates/chat.html) running locally.
| Category | Tools |
|---|---|
| Backend | Python, Flask |
| LLM Framework | LangChain |
| Embeddings & Storage | Pinecone Vector DB |
| LLM Provider | OpenAI (GPT models) |
| Frontend | HTML, CSS, jQuery, Bootstrap |
| Deployment | AWS EC2 + ECR + GitHub Actions (optional) |
To deploy the chatbot using Docker + AWS + CI/CD:
-
IAM User with permissions:
AmazonEC2FullAccessAmazonEC2ContainerRegistryFullAccess
-
ECR Repository for your Docker image Example:
873925794895.dkr.ecr.us-east-1.amazonaws.com/medicalbot
Install Docker:
sudo apt update -y && sudo apt upgrade -y
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ubuntu
newgrp dockerIn your repo → Settings → Actions → Runners → New self-hosted runner Follow the commands displayed for Ubuntu.
| Secret | Description |
|---|---|
AWS_ACCESS_KEY_ID |
IAM access key |
AWS_SECRET_ACCESS_KEY |
IAM secret key |
AWS_DEFAULT_REGION |
e.g. us-east-1 |
ECR_REPO |
ECR image URI |
PINECONE_API_KEY |
Your Pinecone key |
OPENAI_API_KEY |
Your OpenAI key |
- Code pushed → GitHub Actions triggers build
- Docker image built and pushed to ECR
- EC2 runner pulls and runs the latest container
Medical-Chatbot/
│
├── static/
│ └── style.css
├── templates/
│ └── chat.html
│
├── app.py # Flask main app
├── store_index.py # Pinecone index builder
├── requirements.txt
├── .env.example
└── README.md
This chatbot is not a substitute for professional medical advice. Always consult a qualified healthcare provider for any medical condition or emergency.