Skip to content

Repository files navigation

HealthChat Pro

Python Flask LangChain OpenAI Pinecone AWS Docker GitHub Actions

A medical AI assistant powered by LLM technology that provides health information and guidance.

📋 Table of Contents

🔍 Overview

HealthChat Pro is an AI-powered medical assistant application that uses large language models to answer health-related questions. The application features a responsive chat interface built with Flask and leverages LangChain for document retrieval and RAG (Retrieval Augmented Generation) capabilities.

✨ Features

  • Medical Knowledge Base: Access to comprehensive medical information
  • Contextual Responses: AI responses based on medical literature
  • Clean, Responsive UI: Modern dark-themed interface
  • Session Management: Persistent chat sessions
  • Source Citations: References to medical sources
  • Vector Database Integration: Efficient document retrieval using Pinecone

📁 Repository Structure

.
├── data/                   # Medical PDF documents
│   └── Medical_book.pdf    # Sample medical document
├── src/                    # Source code
│   ├── __init__.py
│   ├── helper.py           # Utility functions for document processing
│   └── prompt.py           # System prompts for the AI assistant
├── static/                 # Static assets
│   ├── bot-avatar.svg
│   ├── favicon.svg
│   ├── logo.svg
│   ├── style.css          # CSS styling
│   └── user-avatar.svg
├── templates/              # HTML templates
│   └── chat.html          # Main chat interface
├── .env                    # Environment variables (API keys)
├── .github/               # GitHub configuration
│   └── workflows/         # GitHub Actions workflows
│       └── deploy.yml     # AWS deployment workflow
├── .gitignore             # Git ignore file
├── app.py                 # Main Flask application
├── Dockerfile             # Docker configuration for containerization
├── LICENSE                # Apache License 2.0
├── README.md              # Project documentation
├── requirements.txt       # Python dependencies
├── research/              # Research and development notebooks
│   └── trials.ipynb       # Experimental notebook
├── setup.py              # Package setup file
├── store_index.py        # Script to create and store embeddings
└── template.sh           # Shell script for project setup

🚀 Installation

Prerequisites

  • Python 3.10+
  • Conda (recommended for environment management)
  • Pinecone account
  • OpenAI API key

Setup

  1. Clone the repository
git clone https://github.com/Kaleemullah-Younas/HealthChat-Pro
cd HealthChat-Pro
  1. Create a conda environment
conda create -n healthbot python=3.10 -y
conda activate healthbot
  1. Install dependencies
pip install -r requirements.txt
  1. Create a .env file in the root directory with your API keys (see .env.example for reference)
PINECONE_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
OPENAI_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  1. Store embeddings in Pinecone
python store_index.py
  1. Run the application
python app.py
  1. Open your browser and navigate to http://localhost:8080

💻 Usage

python store_index.py
  1. Start the Flask server
python app.py
  1. Open your browser and navigate to:
http://localhost:8080
  1. Start chatting with the HealthChat Pro AI assistant

🌐 AWS Deployment

Prerequisites

  • AWS Account
  • GitHub Account
  • Docker installed locally (for testing)

AWS Setup

  1. Create IAM User for Deployment

    Create a new IAM user with the following policies:

    • AmazonEC2ContainerRegistryFullAccess
    • AmazonEC2FullAccess
  2. Create ECR Repository

    Create an Elastic Container Registry repository to store your Docker image.

  3. Launch EC2 Instance

    Launch an Ubuntu EC2 instance with appropriate security groups (allow HTTP/HTTPS/SSH).

  4. Install Docker on EC2

    Connect to your EC2 instance and run:

    sudo apt-get update -y
    sudo apt-get upgrade -y
    curl -fsSL https://get.docker.com -o get-docker.sh
    sudo sh get-docker.sh
    sudo usermod -aG docker ubuntu
    newgrp docker
  5. Configure GitHub Actions

    • Go to your GitHub repository
    • Navigate to Settings > Actions > Runners
    • Click "New self-hosted runner"
    • Select Linux as the operating system
    • Follow the instructions to set up the runner on your EC2 instance
  6. Set Up GitHub Secrets

    Add the following secrets to your GitHub repository:

    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_DEFAULT_REGION
    • ECR_REPO
    • PINECONE_API_KEY
    • OPENAI_API_KEY
    • OPENAI_API_BASE
  7. Create GitHub Actions Workflow

    Create a .github/workflows/deploy.yml file in your repository with appropriate CI/CD configuration.

Deployment Process

  1. Push changes to your GitHub repository
  2. GitHub Actions will:
    • Build a Docker image
    • Push the image to ECR
    • Pull and run the image on your EC2 instance

About

HealthChat Pro is an AI-powered medical assistant application that uses large language models to answer health-related questions. The application features a responsive chat interface built with Flask and leverages LangChain for document retrieval and RAG (Retrieval Augmented Generation) capabilities.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages