Skip to content

beastNico/MedTech-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¬ MedTech AI - Intelligent Biomedical Assistant

Python 3.11+ Streamlit LangChain License: MIT

A production-ready, RAG-powered chatbot specialized in biomedical engineering topics. Built with LangChain, FAISS, and Groq LLM for intelligent document-based question answering.

MedTech AI Interface

πŸ“‹ Table of Contents

🌟 Key Features

  • 🧠 RAG Architecture: Retrieval-Augmented Generation for accurate, context-based responses
  • πŸ“š Document Processing: Automatic PDF processing with OCR fallback
  • πŸ’¬ Dual Mode Operation: Technical Q&A + casual conversation support
  • πŸš€ Production Ready: Proper error handling, logging, and monitoring
  • 🐳 Docker Support: One-command deployment with Docker Compose
  • βœ… Tested: Unit tests with pytest
  • πŸ“Š Session Management: Track queries and conversation history

πŸ—οΈ Architecture


β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   User UI   β”‚  (Streamlit)
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   QA Chain Manager  β”‚
β”‚  (LangChain + Groq) β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Vector Store (FAISS)β”‚
β”‚   + Embeddings      β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PDF Documents      β”‚
β”‚  (Technical Docs)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure


MedTech AI/
β”œβ”€β”€ app.py                      # Main Streamlit application
β”œβ”€β”€ main.py                     # Alternative application entry point
β”œβ”€β”€ config.py                   # Centralized configuration
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ Dockerfile                  # Docker container setup
β”œβ”€β”€ docker-compose.yml          # Docker Compose configuration
β”œβ”€β”€ uv.lock                     # Dependency lock file
β”œβ”€β”€ .python-version             # Python version specification
β”œβ”€β”€ view.png                    # Project view image
β”‚
β”œβ”€β”€ core/                       # Core functionality modules
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ vectorstore.py         # FAISS vector store management
β”‚   β”œβ”€β”€ qa_chain.py            # QA chain operations
β”‚   └── document_processor.py   # PDF processing & chunking
β”‚
β”œβ”€β”€ utils/                      # Utility modules
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── logger.py              # Logging configuration
β”‚
β”œβ”€β”€ scripts/                    # Utility scripts
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── build_vectorstore.py   # Index documents script
β”‚
β”œβ”€β”€ tests/                      # Unit tests
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── test_qa.py             # Test suite
β”‚
β”œβ”€β”€ data/                       # PDF documents (add your files here)
β”œβ”€β”€ vectorstore/                # FAISS index storage
β”‚   └── db_faiss/
β”œβ”€β”€ logs/                       # Application logs
β”‚
β”œβ”€β”€ .env.example               # Environment variables template
β”œβ”€β”€ .gitignore                 # Git ignore rules
β”œβ”€β”€ .gitattributes             # Git attributes
β”œβ”€β”€ LICENSE                    # MIT License
└── README.md                  # This file

πŸš€ Quick Start

Prerequisites

  • Python 3.13+
  • Groq API Key (Get one free)
  • PDF documents for your knowledge base

Installation

  1. Clone the repository
git clone https://github.com/beastNico/MedTech-AI.git
cd MedTech-AI
  1. Create virtual environment
python -m venv venv
venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables
copy .env.example .env
# Edit .env and add your GROQ_API_KEY
  1. Add your PDF documents
# Place PDF files in the data/ directory
copy your_documents.pdf data\
  1. Build vector store
python scripts\build_vectorstore.py
  1. Run the application
streamlit run app.py

Visit http://localhost:8501 in your browser!

🐳 Docker Deployment

Using Docker Compose (Recommended)

# Build and run
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Using Docker directly

# Build image
docker build -t medtech-ai .

# Run container
docker run -p 8501:8501 ^
  -v %cd%/data:/app/data ^
  -v %cd%/vectorstore:/app/vectorstore ^
  -e GROQ_API_KEY=your_key_here ^
  medtech-ai

πŸ§ͺ Testing

Run tests with pytest:

# Run all tests
pytest

# Run with coverage
pytest --cov=core --cov=utils

# Run specific test file
pytest tests\test_qa.py -v

πŸ“ Configuration

Edit config.py to customize:

# Model settings
LLM_MODEL = "deepseek-r1-distill-llama-70b"  # Change model
LLM_TEMPERATURE = 0.0                         # Adjust creativity

# Retrieval settings
RETRIEVAL_K = 6                               # Number of docs to retrieve
CHUNK_SIZE = 500                              # Text chunk size
CHUNK_OVERLAP = 50                            # Chunk overlap

🎯 Usage Examples

Casual Chat

User: Hi? Who Are You?
Bot: Hello. I'm a biomedical engineering assistant. It's nice to meet you. How can I assist you today?

Troubleshooting

User: Compare MRI and CT imaging techniques - what are their advantages and limitations?
Bot: Based on the provided context, here is a comparison of MRI and CT imaging techniques:

Advantages of MRI:

Non-invasive procedure
Does not require injecting a contrast medium
Greater sensitivity for detecting disk problems and spinal cord involvement...

API Key Errors

  • Verify your .env file exists
  • Check that GROQ_API_KEY is set correctly
  • Ensure no quotes around the key value

πŸ“Š Performance Metrics

  • Response Time: ~2-4 seconds per query
  • Accuracy: Depends on document quality
  • Uptime: 99%+ with proper deployment
  • Concurrent Users: Supports multiple users (Streamlit limitation)

πŸ› οΈ Technology Stack

Component Technology
Frontend Streamlit
LLM Groq (DeepSeek R1 Distill)
Embeddings HuggingFace (MiniLM)
Vector Store FAISS
Framework LangChain
Document Processing PyPDF + Unstructured
Logging Python logging
Testing Pytest
Containerization Docker

About

RAG based AI Assistant

Resources

License

Stars

Watchers

Forks

Contributors