A production-ready, RAG-powered chatbot specialized in biomedical engineering topics. Built with LangChain, FAISS, and Groq LLM for intelligent document-based question answering.
- π Key Features
- ποΈ System Architecture
- π Quick Start
- π Project Structure
- π³ Docker Deployment
- π§ͺ Testing
- π Configuration
- π― Usage Examples
- π§ Troubleshooting
- π Performance Metrics
- π οΈ Technology Stack
- π§ 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
βββββββββββββββ
β User UI β (Streamlit)
ββββββββ¬βββββββ
β
ββββββββΌβββββββββββββββ
β QA Chain Manager β
β (LangChain + Groq) β
ββββββββ¬βββββββββββββββ
β
ββββββββΌβββββββββββββββ
β Vector Store (FAISS)β
β + Embeddings β
ββββββββ¬βββββββββββββββ
β
ββββββββΌβββββββββββββββ
β PDF Documents β
β (Technical Docs) β
βββββββββββββββββββββββ
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
- Python 3.13+
- Groq API Key (Get one free)
- PDF documents for your knowledge base
- Clone the repository
git clone https://github.com/beastNico/MedTech-AI.git
cd MedTech-AI- Create virtual environment
python -m venv venv
venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Set up environment variables
copy .env.example .env
# Edit .env and add your GROQ_API_KEY- Add your PDF documents
# Place PDF files in the data/ directory
copy your_documents.pdf data\- Build vector store
python scripts\build_vectorstore.py- Run the application
streamlit run app.pyVisit http://localhost:8501 in your browser!
# Build and run
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down# 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-aiRun tests with pytest:
# Run all tests
pytest
# Run with coverage
pytest --cov=core --cov=utils
# Run specific test file
pytest tests\test_qa.py -vEdit 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 overlapUser: Hi? Who Are You?
Bot: Hello. I'm a biomedical engineering assistant. It's nice to meet you. How can I assist you today?
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...
- Verify your
.envfile exists - Check that
GROQ_API_KEYis set correctly - Ensure no quotes around the key value
- Response Time: ~2-4 seconds per query
- Accuracy: Depends on document quality
- Uptime: 99%+ with proper deployment
- Concurrent Users: Supports multiple users (Streamlit limitation)
| 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 |
