Environment Setup

Warning

Our code is developed with Python 3.11. Any other versions may also work, but we do not guarantee compatibility.

Installation

For those who wish to modify the source code or conduct experiments using the complete capabilities of MedAgentGym, we recommend cloning the repository. You can fork the project on GitHub and clone your fork, or directly clone the original repository:

# Clone your fork of the repository
git clone https://github.com/<your GitHub username>/MedAgentGym.git

# Or clone the original repository with git
git clone https://github.com/wshi83/MedAgentGym.git --single-branch --branch main

Anaconda

Using Anaconda is the most straightforward approach to start a new virtual environment for a project. Suppose you have anaconda or miniconda installed in your local machine, you can create a new conda environment for this project using conda create.

conda create -n medagentgym python=3.11

The required packages are listed in requirements.txt. It is recommended to install these dependencies with pip install as conda install may sometimes encounter dependency resolution issue.

conda activate medagentgym
pip install -r requirements.txt

Docker

You can also run this project within a Docker container. To build the Docker image, use the following command through docker build.

docker buildx build -t med_agent_gym:latest .

Once the image is built, you can start the container from your terminal using the docker run command.

docker run \
    --network host \
    --shm-size=64g \
    --gpus='"device=0"' \
    -v ./main.py:/home/main.py \
    -v ./rollout.py:/home/rollout.py \
    -v ./configs:/home/configs \
    -v ./cache:/home/cache \
    -v ./workdir:/home/workdir \
    -v ./entrypoint.sh:/home/entrypoint.sh \
    -v ./credentials.toml:/home/credentials.toml \
    -it med_agent_gym:latest

Please check the official documentation for more options.

Additional Details

Note that MedAgentBench is one of the datasets used for training and evaluation within MedAgentGym. Tasks included in MedAgentBench require interaction with a FHIR-compliant interactive environment and its associated codebase, which must be deployed via a separate Docker instance. We recommend following their Official Guidance. Additionally, we provide detailed instructions below. To sample training data and evaluate models using the MedAgentBench dataset, first start the local FHIR server using Docker with the following commands, and then execute your experiment commands:

docker pull jyxsu6/medagentbench:latest
docker tag jyxsu6/medagentbench:latest medagentbench
docker run -p 8080:8080 medagentbench

After the console indicates that the application has started (e.g., "Started Application in XXX seconds"), you can verify the setup by navigating http://localhost:8080/ in your browser. A FHIR server console should appear if the setup was successful.