--- title: OTC MedGuide emoji: 💊 colorFrom: blue colorTo: green sdk: streamlit sdk_version: "1.28.0" app_file: app.py pinned: false --- # OTC MedGuide A Streamlit-based conversational assistant that provides informational guidance about over-the-counter (OTC) medications and dietary supplements using **Meditron-7B (epfl-llm/meditron-7b)**. ## Features ✅ **Meditron-First Reasoning** - Uses Meditron-7B for medical knowledge and safe recommendations ✅ **OTC Drug Database Enrichment** - Only uses dataset for brand names, dosage, warnings, interactions ✅ **Filtered Recommendations** - Avoids irrelevant drugs (e.g., topicals for headache) ✅ **Table Output** - All recommendations and comparisons are shown in a clear table ✅ **Full OTC Coverage** - Dosage, safety, mechanisms, comparisons, multi-turn follow-ups ✅ **Context Handling** - Tracks previous user input (symptoms, age, pregnancy, medications) for follow-ups ✅ **Friendly, ChatGPT-like UI** - Input at the bottom, single send, sidebar features (user guide, disclaimer, dataset view) ## What It Does - Answers questions about OTC medications using Meditron's medical knowledge - Recommends appropriate OTC drugs for common symptoms (never irrelevant drugs) - Provides general information about medications (uses, warnings, dosage, interactions) - Includes safety disclaimers for medical concerns ## What It Does NOT Do - ❌ Diagnose medical conditions - ❌ Prescribe medications - ❌ Replace professional medical advice - ❌ Recommend prescription drugs ## Requirements - Python 3.9+ - CUDA-capable GPU (recommended for faster inference) - At least 8GB RAM ## Installation ### 1. Clone or Download ```bash cd chatbot ``` ### 2. Create Virtual Environment **Windows (PowerShell):** ```powershell python -m venv .venv .\.venv\Scripts\Activate.ps1 ``` **Linux/Mac:** ```bash python -m venv .venv source .venv/bin/activate ``` ### 3. Install Dependencies ```bash pip install -r requirements.txt ``` **Note:** First-time installation may take 10-15 minutes as it downloads the Phi-3 model (~2.3GB). **Note:** First-time installation may take 10-15 minutes depending on model downloads and your environment. ### Run Tests After installing dependencies, run the unit tests to verify core intent and response behavior: ```bash pytest -q ``` ## License This project uses open-source models and libraries. See individual component licenses. ## Support For issues or questions: - Check the Troubleshooting section - Review application logs in the Streamlit UI - Verify `otc_dataset.json` is valid JSON - Ensure Python 3.9+ is installed --- **Last Updated**: December 17, 2025 **Model**: epfl-llm/meditron-7b docker run -p 8501:8501 otc-chatbot ``` Visit `http://localhost:8501` in your browser. ## Project Structure ``` chatbot/ ├── app.py # Main Streamlit application ├── otc_dataset.json # OTC drug database (100+ drugs) ├── requirements.txt # Python dependencies ├── Dockerfile # Docker configuration ├── README.md # This file └── .venv/ # Virtual environment (created during setup) ``` ## Example Interactions ### Example 1: Greeting ``` User: Hi Bot: Hello! I'm an OTC drug recommendation assistant. You can ask me about symptoms, medications, or general health concerns. ``` ### Example 2: Symptom Inquiry ``` User: I have a headache Bot: For headaches, you might consider acetaminophen or ibuprofen. Acetaminophen (Tylenol) is effective for mild to moderate headaches and is generally well-tolerated. Ibuprofen (Advil, Motrin) is an anti-inflammatory that works well for tension headaches... [includes safety warnings] ``` ### Example 3: Medication Information ``` User: What are the side effects of ibuprofen? Bot: Ibuprofen warnings include: - GI bleeding risk (especially with long-term use) - Cardiovascular risk with chronic use - Kidney effects in susceptible individuals - Should be taken with food to minimize stomach upset [includes appropriate disclaimers] ``` ## Model Information - **Model**: `epfl-llm/meditron-7b` - **Size**: ~14GB (quantized) - **Type**: Medical language model - **Context Window**: 4096 tokens - **Capabilities**: Medical reasoning, drug information, safety-aware responses ### Why Meditron? - ✅ Specialized for medical Q&A and reasoning - ✅ High-quality medical knowledge and safety awareness - ✅ Excellent for OTC medication recommendations - ✅ Local inference for privacy and reliability ## Configuration Key parameters in `app.py`: ```python MODEL_ID = "epfl-llm/meditron-7b" MAX_NEW_TOKENS = 512 # Max tokens per response TEMPERATURE = 0.6 # Higher = more creative TOP_P = 0.95 # Nucleus sampling parameter ``` Adjust these values in the code if needed. ## Safety & Compliance - **Medical Disclaimer**: Automatically displayed to users - **Non-Diagnostic**: Does not diagnose or treat diseases - **Informational Only**: Provides general guidance, not medical advice - **Professional Referral**: Recommends seeing healthcare providers for serious symptoms - **Pregnancy/Breastfeeding**: Includes safety warnings ## Performance Notes - **First Run**: Model downloads (~14GB). Subsequent runs load from cache (much faster) - **Inference Time**: 5-15 seconds per response (depends on hardware) - **Memory**: ~8-16GB RAM during inference - **GPU**: Highly recommended for <10s response times ## Troubleshooting ### Model Takes Too Long to Load - First-time download is large. Check internet connection - For CPU-only systems, expect longer load times - Consider GPU access for faster inference ### Out of Memory Errors - Reduce `MAX_NEW_TOKENS` to 128 in `app.py` - Close other applications - Use Docker for isolated environment ### Streamlit Port Already in Use ```bash streamlit run app.py --server.port 8502 ``` ### Import Errors ```bash pip install --upgrade transformers torch ``` ## File Descriptions ### `app.py` Main application entry point. Contains: - Model loading and caching - OTC dataset retrieval and matching - Response generation with Meditron-7B - Streamlit UI components - Chat history management ### `otc_dataset.json` Structured database of 100+ OTC drugs with fields: - `generic_name`: Drug's generic name - `brand_names`: Brand names (e.g., Tylenol, Advil) - `category`: Drug category (Pain/Fever, Allergy, etc.) - `common_use`: Primary uses - `warnings`: Safety warnings - `interactions`: Known drug interactions - Other fields for dosage, contraindications, pregnancy flags, etc. ### `requirements.txt` Python packages required: - `streamlit`: Web UI framework - `transformers`: HF transformer models and pipelines - `torch`: Deep learning framework (with CUDA support) - `pandas`: Data manipulation - `accelerate`: Distributed computing for faster inference ### `Dockerfile` Container configuration for deployment: - Python 3.11-slim base - Installs all dependencies - Copies application files - Exposes port 8501 - Runs Streamlit server ## License This project uses open-source models and libraries. See individual component licenses. ## Support For issues, questions, or improvements: 1. Check the Troubleshooting section 2. Review application logs in Streamlit UI 3. Verify `otc_dataset.json` is valid JSON 4. Check Python version compatibility (3.9+) --- **Last Updated**: December 16, 2025 **Last Updated**: December 17, 2025 **Model**: epfl-llm/meditron-7b