https://github.com/kingabzpro/medical-ai-with-grok4
Medical prescription AI application that allows users to upload their prescriptions and find information about the medicine's price, availability, and dosage duration.
https://github.com/kingabzpro/medical-ai-with-grok4
Last synced: about 5 hours ago
JSON representation
Medical prescription AI application that allows users to upload their prescriptions and find information about the medicine's price, availability, and dosage duration.
- Host: GitHub
- URL: https://github.com/kingabzpro/medical-ai-with-grok4
- Owner: kingabzpro
- License: apache-2.0
- Created: 2025-07-25T09:52:20.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-07-25T18:17:10.000Z (3 months ago)
- Last Synced: 2025-07-25T23:28:05.740Z (3 months ago)
- Language: Jupyter Notebook
- Size: 1.18 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MedGuide AI: Prescription Analyzer
[](https://www.python.org/downloads/)
[](https://gradio.app/)
[](https://opensource.org/license/apache-2-0)A powerful AI-driven medical prescription analyzer that extracts medicine information from prescription images and provides comprehensive reports including prices, availability, dosage, and purchase links. Features a modern, clean interface with real-time streaming progress and collapsible sections for optimal user experience.
https://github.com/user-attachments/assets/20590d86-04ba-483b-b5b3-0b3fef4a9e3c
## β¨ Key Features
### π **Advanced AI Analysis**
- **Smart OCR**: Extract medicine names from prescription images using Grok-4 AI
- **Concurrent Processing**: Fetch multiple medicine details simultaneously for faster results
- **Real-time Streaming**: Watch AI work step-by-step with live progress updates
- **Optimized Performance**: Ultra-fast medicine lookup with aggressive optimization and fallback handling### π¨ **Modern User Interface**
- **Clean Design**: Professional Gradio web interface with intuitive layout
- **Smart Button States**: Button automatically disables during processing to prevent duplicate requests
- **Collapsible Logs**: Optional detailed processing logs hidden by default for clean UX
- **Collapsible Disclaimer**: Important medical warnings in expandable section
- **Responsive Layout**: Optimized for both desktop and mobile viewing### π **Comprehensive Reports**
- **Live Report Streaming**: Watch AI generate your medical report in real-time with streaming text updates
- **Structured Information**: Detailed markdown reports with medicine descriptions
- **Price & Availability**: Real-time pricing and purchase information
- **Processing Transparency**: Full visibility into AI decision-making process
- **Error Handling**: Robust error handling with informative feedback## π οΈ Technology Stack
- **AI Model**: Grok-4 by xAI for image analysis and text extraction
- **Web Framework**: Gradio for the user interface
- **Data Source**: Firecrawl API for medicine information retrieval
- **Image Processing**: PIL (Python Imaging Library)
- **Concurrency**: ThreadPoolExecutor for parallel processing## π Prerequisites
- Python 3.8 or higher
- xAI API key (for Grok-4 access)
- Firecrawl API key (for medicine data retrieval)## π Quick Start
### 1. Clone the Repository
```bash
git clone https://github.com/kingabzpro/Medical-AI-with-Grok4.git
cd Medical-AI-with-Grok4
```### 2. Install Dependencies
```bash
pip install -r requirements.txt
```### 3. Set Up Environment Variables
Copy the example environment file and add your API keys:
Create the `.env` file with your actual API keys:
```env
XAI_API_KEY=your_xai_api_key_here
FIRECRAWL_API_KEY=your_firecrawl_api_key_here
```### 4. Run the Application
```bash
python app.py
```The application will start and be available at `http://localhost:7860`
## π― How to Use
### Basic Workflow
1. **Upload Image**: Click on the "Upload Prescription Image" area and select your prescription photo
2. **Analyze**: Click the "Analyze Prescription" button (button automatically changes to "β³ Processing..." and disables to prevent duplicate requests)
3. **Monitor Progress**: Watch real-time processing updates in the main area and detailed logs in the collapsible section
4. **Live Streaming**: Experience real-time report generation as the AI streams the final medical report text
5. **View Results**: Get comprehensive medicine information including:
- Medicine description and usage
- Typical treatment duration
- Price information and availability
- Purchase links and sources
- Total processing time### ποΈ Interface Features
#### **Main Report Area**
- Shows processing status during analysis
- Displays clean, formatted final report
- No technical clutter for better readability#### **Processing Logs (Collapsible)**
- Click "π Processing Logs" to expand detailed technical information
- View step-by-step AI analysis process
- Monitor API calls and responses
- Useful for debugging and transparency
- Hidden by default to keep interface clean#### **Medical Disclaimer (Collapsible)**
- Click "β οΈ Medical Disclaimer" to expand important safety information
- Contains crucial warnings about AI limitations
- Emphasizes need for professional medical consultation
- Legal and safety guidelines for responsible use## ποΈ Architecture
```
βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
β Gradio UI ββββΆβ Grok-4 AI βββββΆβ Firecrawl API β
β (Frontend) β β (Agent & VLM) β β (Search & Scrape)β
βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
β β β
β βΌ β
β βββββββββββββββββββ β
ββββββββββββββββ Python Backend ββββββββββββββββ
β (Coordination) β
βββββββββββββββββββ
```## π Project Structure
```
Medical-AI-with-Grok4/
βββ app.py # Main application file
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .env # Your environment variables (not in git)
βββ README.md # Project documentation
βββ .gitignore # Git ignore file
```## π¨ Important Notes
- **Medical Disclaimer**: This tool is for informational purposes only and should not replace professional medical advice
- **Privacy**: Images are processed locally and not stored permanently
- **API Limits**: Be aware of rate limits for both xAI and Firecrawl APIs
- **Accuracy**: AI extraction may not be 100% accurate; always verify medicine information