MedGraph-AI is a multi-agent medical assistant built with LangGraph and LangChain. It unifies medical knowledge question answering, time-sensitive web retrieval, and medical image analysis under one routed workflow, then adds human review for high-risk outputs.
MedGraph-AI focuses on three connected medical workflows:
- Multi-agent medical Q&A routed by LangGraph.
- Medical-domain RAG powered by LangChain, Qdrant, and local embeddings.
- Medical image analysis pipelines with reviewer-in-the-loop handling.
The system is designed as an engineering-oriented project rather than a single demo script. FastAPI and Chainlit provide unified chat, upload, and review entrypoints. SQLite persists chat history and graph checkpoints to support multi-turn conversations, recovery, and review continuity.
LangGraph acts as the workflow backbone. A supervisor decides whether an incoming request should go to:
- a general medical conversation flow,
- the RAG pipeline,
- the web search flow for time-sensitive information,
- or an image-analysis flow followed by human review.
This keeps routing explicit, makes state transitions traceable, and keeps outputs easier to control in higher-risk medical scenarios.
The retrieval layer combines LangChain components with Qdrant-based storage to build a medical-domain RAG workflow. The current implementation includes:
- document parsing and content preparation,
- local embedding generation,
- vector retrieval and reranking,
- source-aware answer generation,
- and Tavily-backed web search for recent external information.
This lets the project answer knowledge-base questions while still supplementing with timely web results when needed.
Image-analysis capabilities are wired into the same multi-agent workflow. The repository includes processing paths for:
- chest X-ray classification,
- skin lesion segmentation,
- brain MRI tumor-oriented screening.
For high-risk outputs, the system routes results into a reviewer flow instead of returning them directly. This makes human intervention and review tracking first-class parts of the application rather than an afterthought.
FastAPI and Chainlit are split by responsibility:
- FastAPI exposes API endpoints, upload handling, and service orchestration.
- Chainlit provides the interactive review and conversation interface.
- SQLite persists chat threads and LangGraph checkpoint state.
This layered structure helps with maintainability, restart recovery, and operational clarity.
Primary stack:
- LangGraph
- LangChain
- FastAPI
- Chainlit
- Qdrant
- Ollama
- SQLite
- Tavily
Supporting components:
- Docling for document parsing
- PyTorch-based medical vision models
- Hugging Face reranker models
- ElevenLabs speech endpoints
- User sends a medical question.
- Supervisor routes it to conversation, RAG, or web search.
- Result is returned with agent output metadata and optional references.
- Web search is used when up-to-date information is needed.
- Tavily supplements local knowledge with recent external content.
- The final response stays within the same LangGraph-orchestrated pipeline.
- User uploads an image with optional context.
- The image is classified into the correct analysis route.
- Model output is sent into the review flow before final response delivery.
.
|-- agents/ # Multi-agent routing, RAG, web search, image analysis
|-- assets/ # Flowchart
|-- data/
| |-- raw/ # Source documents kept for ingestion
| `-- raw_extras/ # Additional source materials
|-- docs/
| `-- README.zh-CN.md # Public Chinese project description
|-- sample_images/ # Example inputs for image workflows
|-- templates/ # Legacy web template assets
|-- tests/ # Targeted tests
|-- app.py # FastAPI entrypoint
|-- chainlit_app.py # Chainlit app integration
|-- config.py # Central configuration
`-- ingest_rag_data.py # RAG ingestion utility
git clone <your-github-repository-url>
cd MedGraph-AIUse the provided template:
cp .env.example .envThen update the keys and local service endpoints in .env.
Recommended with uv:
uv syncuv run python app.pyThe root path redirects to Chainlit. By default the app is available at:
http://localhost:8000
uv run python ingest_rag_data.py --dir ./data/raw- This project is an engineering portfolio project and research-oriented prototype, not a medical device.
- High-risk image outputs should always go through reviewer validation.
- Large local runtime artifacts, vector stores, checkpoint data, and uploads are intentionally excluded from version control.
This project is licensed under the Apache-2.0 License. See LICENSE.
