Spaces:
Runtime error
Runtime error
| 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/) | |
| [](tests/) | |
| [](src/) | |
| [](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. | |