Skip to content

Repository files navigation

πŸ₯ MediBlaze AI - Advanced Medical Assistant

MediBlaze is an intelligent AI-powered medical assistant that provides comprehensive health information through a modern web interface. It combines medical knowledge base retrieval (RAG) with real-time web search to deliver accurate, up-to-date health guidance.

✨ Features

🧠 AI-Powered Health Assistant

  • Advanced medical knowledge base with RAG (Retrieval Augmented Generation)
  • Real-time web search for latest medical information
  • Smart tool selection - uses RAG first, web search when needed
  • Comprehensive health domain coverage

🎯 Health Domains Covered

  • Diseases & Conditions: Symptoms, causes, diagnosis, complications
  • Treatments & Medications: Therapies, drug information, side effects
  • Preventive Health: Lifestyle changes, diet, exercise, wellness
  • Sexual Health & Education: Reproductive health, contraception, STI prevention
  • Mental Health: Stress management, emotional well-being
  • Nutrition: Dietary guidance, eating habits, food safety
  • Body Changes: Growth, aging, hormonal changes
  • Health Safety: First aid, injury prevention

πŸ’» Modern Web Interface

  • Real-time streaming responses with markdown rendering
  • Tool usage indicators ("Thinking...", "Searching web...")
  • Responsive design with beautiful UI/UX
  • Professional medical styling with health emojis

πŸ”§ Technical Features

  • FastAPI backend with async streaming
  • LangGraph agent workflow
  • Google Gemini AI integration
  • Pinecone vector database for RAG
  • Real-time Server-Sent Events (SSE)
  • Markdown to HTML rendering

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Google AI API Key
  • Pinecone API Key

Installation

  1. Clone the repository
git clone <repository-url>
cd __MEDIBLAZE
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables Create a .env file in the root directory:
GOOGLE_API_KEY=your_google_ai_api_key_here
PINECONE_API_KEY=your_pinecone_api_key_here
  1. Run the application
python main.py
  1. Access the interface Open your browser and navigate to: http://localhost:8000

🐳 Docker Deployment

Build and run with Docker

# Build the image
docker build -t mediblaze .

# Run the container
docker run -p 8000:8000 \
  -e GOOGLE_API_KEY=your_key \
  -e PINECONE_API_KEY=your_key \
  mediblaze

Docker Compose (Recommended)

# Create docker-compose.yml with your environment variables
docker-compose up -d

πŸ“ Project Structure

__MEDIBLAZE/
β”œβ”€β”€ main.py                 # FastAPI application entry point
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ Dockerfile             # Docker configuration
β”œβ”€β”€ docker-compose.yml     # Docker Compose setup
β”œβ”€β”€ .env                   # Environment variables (create this)
β”œβ”€β”€ README.md              # This file
β”‚
β”œβ”€β”€ agent/                 # AI Agent components
β”‚   β”œβ”€β”€ agent.py          # LangGraph agent workflow
β”‚   └── utils/
β”‚       β”œβ”€β”€ prompt.py     # System prompts and instructions
β”‚       └── tools.py      # RAG and web search tools
β”‚
β”œβ”€β”€ templates/             # Frontend templates
β”‚   └── index.html        # Main web interface
β”‚
β”œβ”€β”€ static/               # Static assets
β”‚   β”œβ”€β”€ styles.css       # Custom CSS styles
β”‚   β”œβ”€β”€ doctor-avatar.png # AI assistant avatar
β”‚   └── user-avatar.png   # User avatar
β”‚
└── Data/                 # Knowledge base
    └── Book.pdf         # Medical knowledge source

πŸ”§ API Endpoints

GET /

Main web interface

POST /chat

Standard chat endpoint

{
  "message": "What are the symptoms of diabetes?"
}

POST /chat/stream

Streaming chat with real-time responses

{
  "message": "How to manage stress naturally?"
}

GET /health

Health check endpoint

GET /docs

Interactive API documentation

🧠 How It Works

Smart Tool Selection Process:

  1. RAG First: Searches medical knowledge base for foundational information
  2. Evaluate: Determines if RAG information is complete and current
  3. Web Search: Only used when RAG is insufficient for:
    • Recent medical developments
    • Specific lifestyle advice not in knowledge base
    • Current medication information
    • Sexual health education topics
    • Detailed procedures and guidelines

Response Format:

All responses follow a structured medical format:

## πŸ₯ [Topic Title with Health Emoji]

[Brief overview explaining the topic]

**🎯 Key Points:**

- Point 1 with specific health details
- Point 2 with relevant information
- Point 3 with important facts

**πŸ’Š Treatment/Management:**

- Primary treatment approaches
- Lifestyle recommendations
- Prevention strategies

---

> ⚠️ **Important**: Consult healthcare professionals for personalized advice.

πŸ›‘οΈ Important Disclaimers

  • Educational Purpose Only: MediBlaze provides educational health information, not medical diagnosis
  • Not Emergency Care: For medical emergencies, contact emergency services immediately
  • Consult Professionals: Always consult qualified healthcare professionals for personalized medical advice
  • No Diagnosis: This tool does not replace professional medical consultation

πŸ” Environment Variables

Variable Description Required
GOOGLE_API_KEY Google AI (Gemini) API key Yes
PINECONE_API_KEY Pinecone vector database API key Yes

πŸ§ͺ Testing

Test the application with curl:

# Health check
curl http://localhost:8000/health

# Chat endpoint
curl -X POST "http://localhost:8000/chat" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are the symptoms of diabetes?"}'

# Streaming endpoint
curl -N "http://localhost:8000/chat/stream" \
  -H "Content-Type: application/json" \
  -d '{"message": "How to maintain good oral hygiene?"}'

Example Questions to Try:

  • "What are the symptoms of diabetes?"
  • "How to manage stress naturally?"
  • "What foods are good for heart health?"
  • "How to maintain good oral hygiene?"
  • "What are the benefits of regular exercise?"
  • "How to improve sleep quality?"

πŸ”„ Development

Adding New Health Topics:

  1. Update knowledge base in Data/ directory
  2. Modify system prompt in agent/utils/prompt.py
  3. Test with various health queries

Customizing UI:

  • Modify templates/index.html for layout changes
  • Update static/styles.css for styling
  • Add new avatars in static/ directory

πŸ“ License

This project is for educational and informational purposes. Please ensure compliance with medical information regulations in your jurisdiction.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“ž Support

For issues or questions:

  • Check the API documentation
  • Review the health check endpoint
  • Ensure all environment variables are set correctly

⚠️ Medical Disclaimer: This AI assistant provides educational health information only. Always consult qualified healthcare professionals for medical advice, diagnosis, and treatment. In case of medical emergency, contact emergency services immediately.

About

AI medical assistant with RAG and real-time web search, built using LangGraph, Gemini AI, and FastAPI. Educational, modular, and beginner-friendly.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages