MediRAG-API / README.md
joytheslothh's picture
deploy: clean build
b6f9fa8
metadata
title: MediRAG API
emoji: πŸ₯
colorFrom: blue
colorTo: green
sdk: docker
pinned: false

MediRAG Backend - Hugging Face Spaces (Docker)

πŸ₯ Medical RAG System with Hallucination Detection

This is the backend API for MediRAG 2.0, designed to work with a React frontend.

🐳 Docker Deployment

This Space provides the backend API. The React frontend connects to this backend.

Backend Features

  • πŸ” Hybrid Retrieval: FAISS (BioBERT) + BM25 keyword search
  • 🧠 LLM Generation: Mistral/Gemini for medical answer generation
  • πŸ›‘οΈ 4-Layer Audit: Faithfulness, Entity Verification, Source Credibility, Contradiction Detection
  • ⚠️ Safety Interventions: Auto-blocks high-risk responses
  • πŸ“Š Health Risk Score (HRS): 0-100 composite safety metric
  • πŸ”Œ REST API: Full FastAPI endpoints for React frontend

πŸš€ Usage

For React Frontend

Connect your React app to this backend:

const API_URL = "https://joytheslothh-medirag-api.hf.space";

API Endpoints

  • GET /health - Health check
  • POST /query - Full RAG pipeline
  • POST /evaluate - Evaluate answer
  • GET /docs - Swagger API documentation

Environment Variables

Set in Hugging Face Space settings:

  • MISTRAL_API_KEY - For Mistral LLM
  • GOOGLE_API_KEY - For Gemini LLM

πŸ—οΈ Architecture

React Frontend β†’ FastAPI Backend β†’ RAG Pipeline β†’ Response

⚠️ Disclaimer

This system is for research purposes only. Always consult qualified medical professionals for health decisions.

πŸ“„ License

MIT License - See repository for details.