Agentic-RagBot / README.md
MediGuard AI
fix: Add HuggingFace Spaces configuration metadata
186b228
|
Raw
History Blame Contribute Delete
7.21 kB
---
title: MediGuard AI
emoji: πŸ₯
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: "3.13"
python_version: "3.13"
app_file: app.py
pinned: false
license: mit
---
# MediGuard AI: Multi-Agent RAG System for Medical Biomarker Analysis
[![Tests](https://img.shields.io/badge/tests-148%20passing-brightgreen)](tests/)
[![Coverage](https://img.shields.io/badge/coverage-58%25-yellow)](tests/)
[![Security](https://img.shields.io/badge/security-passing-brightgreen)](src/)
[![Code Quality](https://img.shields.io/badge/code%20quality-passing-brightgreen)](src/)
> **⚠️ Disclaimer:** This is an AI-assisted analysis tool, NOT a medical device. Always consult healthcare professionals for medical decisions.
A production-ready biomarker analysis system combining 6 specialized AI agents with medical knowledge retrieval (RAG) to provide evidence-based insights on blood test results.
## πŸš€ Quick Start
### Prerequisites
- Python 3.13+
- 8GB+ RAM
- Ollama (for local LLM) or Groq API key
### Installation (5 minutes)
```bash
# Clone the repository
git clone https://github.com/yourusername/Agentic-RagBot.git
cd Agentic-RagBot
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# or
.venv\\Scripts\\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure environment (copy .env.example to .env)
cp .env.example .env
# Edit .env with your API keys
# Initialize embeddings
python scripts/setup_embeddings.py
# Start the application
python -m src.main
```
### Docker Alternative
```bash
# Build and run with Docker
docker build -t mediguard-ai .
docker run -p 8000:8000 -p 7860:7860 mediguard-ai
```
## πŸ—οΈ Architecture
### Multi-Agent Workflow
```
Input β†’ Validation β†’ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β†’ Output
β”‚ 6 Specialist Agents β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ Biomarker Analyzer β”‚
β”‚ β€’ Disease Explainer β”‚
β”‚ β€’ Biomarker Linker β”‚
β”‚ β€’ Clinical Guidelines Agent β”‚
β”‚ β€’ Confidence Assessor β”‚
β”‚ β€’ Response Synthesizer β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
### Key Components
- **Agents**: 6 specialized AI agents for different analysis aspects
- **Knowledge Base**: Medical literature in vector database (FAISS/OpenSearch)
- **State Management**: LangGraph for workflow orchestration
- **API Layer**: FastAPI with async support
- **Web UI**: Gradio interface for interactive use
## πŸ“Š Features
- **🧬 Biomarker Analysis**: Analyzes 80+ biomarker aliases mapped to 24 canonical names
- **🎯 Disease Scoring**: Rule-based heuristics for 5 major conditions
- **πŸ“š Evidence-Based**: All recommendations backed by medical literature
- **πŸ”’ HIPAA Compliant**: Audit logging and security headers
- **πŸš€ Production Ready**: Error handling, monitoring, and scalability
- **πŸ”§ Configurable**: Environment-based configuration
- **πŸ“– Multiple Interfaces**: CLI, REST API, and Web UI
## 🎯 Disease Detection
The system uses rule-based heuristics to score disease likelihood:
| Disease | Key Indicators | Threshold |
|---------|----------------|-----------|
| Diabetes | Glucose, HbA1c | Glucose > 126, HbA1c β‰₯ 6.5 |
| Anemia | Hemoglobin, MCV | Hgb < 12, MCV < 80 |
| Heart Disease | Cholesterol, Troponin | Chol > 240, Troponin > 0.04 |
| Thrombocytopenia | Platelets | Platelets < 150,000 |
| Thalassemia | MCV + Hgb pattern | MCV < 80 + Hgb < 12 |
## πŸ› οΈ Usage
### REST API
```bash
# Start the server
uvicorn src.main:app --reload
# Analyze biomarkers
curl -X POST http://localhost:8000/analyze/structured \\
-H "Content-Type: application/json" \\
-d '{"biomarkers": {"Glucose": 140, "HbA1c": 10.0}}'
# Ask medical questions
curl -X POST http://localhost:8000/ask \\
-H "Content-Type: application/json" \\
-d '{"question": "What does high HbA1c mean?"}'
```
### Python SDK
```python
from src.workflow import create_guild
from src.state import PatientInput
# Create workflow
guild = create_guild()
# Analyze patient data
patient_input = PatientInput(
biomarkers={"Glucose": 140, "HbA1c": 10.0},
patient_context={"age": 45, "gender": "male"},
model_prediction={"disease": "Diabetes", "confidence": 0.9}
)
result = guild.run(patient_input)
print(result["final_response"])
```
### Web Interface
```bash
# Launch Gradio UI
python -m src.gradio_app
# Visit http://localhost:7860
```
## πŸ“ Project Structure
```
Agentic-RagBot/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ agents/ # Agent implementations
β”‚ β”œβ”€β”€ services/ # Core services (retrieval, embeddings)
β”‚ β”œβ”€β”€ routers/ # FastAPI endpoints
β”‚ β”œβ”€β”€ models/ # Data models
β”‚ β”œβ”€β”€ state.py # State management
β”‚ β”œβ”€β”€ workflow.py # Workflow orchestration
β”‚ └── main.py # Application entry point
β”œβ”€β”€ tests/ # Test suite (58% coverage)
β”œβ”€β”€ scripts/ # Utility scripts
β”œβ”€β”€ docs/ # Documentation
β”œβ”€β”€ data/ # Data files
└── docker/ # Docker configurations
```
## πŸ§ͺ Testing
```bash
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=src --cov-report=html
# Run specific test suites
pytest tests/test_agents.py
pytest tests/test_workflow.py
```
## πŸ”§ Configuration
Key environment variables:
```bash
# API Configuration
API__HOST=127.0.0.1
API__PORT=8000
# LLM Configuration
GROQ_API_KEY=your_groq_key
# or
OLLAMA_BASE_URL=http://localhost:11434
# Database
OPENSEARCH_HOST=localhost
OPENSEARCH_PORT=9200
# Cache
REDIS_URL=redis://localhost:6379
```
## πŸ“ˆ Performance
- **Response Time**: < 2 seconds for typical analysis
- **Throughput**: 100+ concurrent requests
- **Memory Usage**: ~2GB base + embeddings
- **Test Coverage**: 58% (148 passing tests)
## πŸ”’ Security
- HIPAA-compliant audit logging
- Security headers middleware
- Input validation and sanitization
- No hardcoded secrets
- Regular security scans (Bandit)
## 🀝 Contributing
1. Fork the repository
2. Create a feature branch
3. Write tests for new functionality
4. Ensure all tests pass
5. Submit a pull request
See [DEVELOPMENT.md](DEVELOPMENT.md) for detailed guidelines.
## πŸ“„ License
MIT License - see [LICENSE](LICENSE) for details.
## πŸ™ Acknowledgments
- Medical literature from NIH and WHO
- LangChain and LangGraph for agent framework
- FAISS for vector similarity search
- FastAPI for web framework
## πŸ“ž Support
- πŸ“§ Email: support@mediguard-ai.com
- πŸ“– Documentation: [docs/](docs/)
- πŸ› Issues: [GitHub Issues](https://github.com/yourusername/Agentic-RagBot/issues)
---
**⚑ Ready to deploy?** See [DEPLOYMENT.md](DEPLOYMENT.md) for production deployment guide.