MedAgent: Medical Guidelines Recommendation System Based on Retrieval Augmented Retrieval and Agentic AI Workflows
This is official repo for "MedAgent: Medical Guidelines Recommendation System Based on Retrieval Augmented Retrieval and Agentic AI Workflows" by DBIS at RWTH Aachen University (Yongli Mou*, Hanbin Chen, Meret Unbehaun, Saif Nasir and Stefan Decker) and University Hospital Aachen (Nadine Γnelmis and Behrus Puladi)
The Medical Guidelines Recommendation System (MedAgent) is an advanced AI-powered solution designed to assist healthcare professionals in making informed medical decisions by providing personalized, evidence-based medical guidelines. This system leverages the capabilities of Large Language Models (LLMs) and Agentic AI workflows to create a robust framework for dynamic interaction between users (doctors) and the system, and to facilitate continuous learning and adaptation through a Retrieve-and-Generate (RAG) pipeline.
-
Large Language Models (LLMs): At the core of the system, LLMs such as GPT-based models are utilized to understand medical queries and generate responses in natural language, ensuring that recommendations are presented in an intuitive, easy-to-understand format for doctors.
-
Agentic AI Workflow: This component enables the system to perform complex tasks autonomously. It orchestrates the interaction between different models and databases, ensuring a smooth process for retrieving relevant medical guidelines, processing them, and providing actionable insights. The agentic behavior allows the system to adapt to different contexts based on user input and system status.
-
RAG Pipeline: The system integrates the Retrieve-and-Generate (RAG) pipeline, which enables it to query relevant databases for up-to-date medical information. This includes using retrieval-based techniques to extract the most relevant data from external sources (e.g., medical research, guidelines databases) and then generating personalized recommendations or explanations for the doctor.
Role-based Interactions: The system is designed to serve two primary user roles:
- Doctors (End-users): They interact with the system to receive medical recommendations, guidelines, and insights based on patient data and clinical queries.
- Knowledge Maintainers (Developers): These users are responsible for keeping the system's knowledge base up to date, ensuring that medical guidelines and AI models are regularly improved and trained to handle emerging medical trends and innovations.
-
Frontend (Next.js): The user interface is built with Next.js, providing a modern, responsive, and fast application where doctors can input queries, review recommendations, and interact with the AI-powered assistant. The frontend communicates with the backend to handle the logic and AI operations.
-
Backend (FastAPI): The backend is built with FastAPI, handling API requests, interacting with databases, running AI models, and serving the AI-generated guidelines and recommendations to the frontend.
-
Databases:
- MongoDB and Postgres is used to store and manage study data, user interactions, and structured medical data.
- Neo4j (Graph Database) is used for knowledge representation, allowing the system to model medical relationships, such as drug interactions or disease pathways.
- Vector Database (e.g., FAISS or similar) is employed to store and query embeddings of medical guidelines and knowledge for efficient retrieval.
-
Authentication & Security: The system uses Keycloak for secure authentication and user management. This ensures that only authorized personnel (e.g., doctors and developers) can access the system and modify sensitive data.
-
Notebooks is temporarily added as a start for trying out the backend API and demonstrating the intended study performed during the interactive development proces
- Python 3.10 or higher
- Node.js 18 or higher
- Conda package manager
- npm package manager
We provide a convenient script to start both frontend and backend services simultaneously:
# Add execution permission
chmod +x start.sh
# Run the script
./start.shThe script will automatically:
- Check for required dependencies
- Create and activate conda environment (if not exists)
- Install required dependencies
- Start backend service (http://127.0.0.1:8000)
- Start frontend service (http://localhost:3000)
You can use Ctrl+C to stop all services at once.
If you prefer to control the deployment process manually, follow these steps:
- Create and activate Conda environment
# Create environment
conda create --name medagent python=3.10
# Activate environment
conda activate medagent
# Navigate to backend directory
cd backend
# Install dependencies
pip install -e .- Start backend service
# Start in development mode (with hot reload)
python -m uvicorn app.main:app --reloadThe service will run at http://127.0.0.1:8000
- Install dependencies
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install- Start development server
npm run devThe frontend will run at http://localhost:3000
Here's an example of how to use the model:
from api.llms.azure import AzureChatCompletion
llm = AzureChatCompletion(azure_endpoint="https:your_endpoint.azure.com", azure_deployment="your_deployment_name", azure_api="your_azure_api", azure_api_version="your_api_version")More detailed tutorials can be found in our documentation.
π¦ MedAgent
βββ π docs # Documentation and API references
βββ π frontend
βββ π backend
βββ π docker
β βββ π keycloak
β βββ π frontend
β βββ π backend
β βββ ...
β βββ docker-compose.yml
βββ Makefile
βββ LICENSE
βββ README.md
| Model | MedQA | OMSRec |
|---|---|---|
| TransE | xx | xx |
More benchmarks are available in the research paper.
MedAgent supports English, Chinese, and German languages, implemented using react-i18next and i18next with dynamic language switching, JSON translation texts, and modularized file structure. To add a new language, update settings.ts, create a new language folder, add a translation file, and update the language switcher component.
More information in the i18n README
This project is licensed under the MIT License. See the LICENSE file for details.
If you use this project in your research, please cite:
@article{mou2025MedAgent,
author = {Yongli Mou, Hanbin Chen, Meret Unbehaun, Saif Nasir, Nadine Γnelmis, Behrus Puladi and Stefan Decker},
title = {MedAgent: Medical Guidelines Recommendation System Based on Retrieval Augmented Retrieval and Agentic AI Workflows},
journal = {XXX},
year = {202X}
}We provide a convenient script to start both the frontend and backend services simultaneously:
# Add execution permission
chmod +x start.sh
# Run the script
./start.shThis script will automatically:
- Check if the necessary dependencies are installed
- Create and activate the conda environment (if it doesn't exist)
- Install the required dependencies
- Start the backend service (http://127.0.0.1:8000)
- Start the frontend service (http://localhost:3000)
You can use Ctrl+C to stop all services simultaneously.