yatin-superintelligence/digital-hospital-environment
Digital Hospital Environment
Digital Hospital is a deterministic clinical AI environment for evaluating and training agents that operate inside a hospital workflow. It is served as a FastAPI Space and exposes standard HTTP endpoints for episode reset, step execution, state inspection, closing, cross-role email injection, and clinic-data injection.
The environment contains 11 hospital roles, 47 patient cases, 550 role-specific MCQs, hidden answer keys, specialty-specific tool permissions, deterministic grading, dense per-step rewards, a Clinical Research Expert inbox workflow, a Hospital Director review workflow, and trajectory capture for offline reinforcement learning or process-supervision datasets.
Roles
API Usage
Set the Space URL:
export ENV_URL="https://yatin-superintelligence-digital-hospital-environment.hf.space"Check health:
curl "$ENV_URL/health"Start a single role episode:
curl -X POST "$ENV_URL/reset" \
-H "Content-Type: application/json" \
-d '{"role_id":"S01","seed":42,"session_id":"demo-s01"}'Take a step:
curl -X POST "$ENV_URL/step" \
-H "Content-Type: application/json" \
-d '{
"session_id": "demo-s01",
"command": "answer_mcq",
"arguments": {"answer": "B"},
"reasoning": "Choose the best role-specific answer."
}'Inspect available actions:
curl "$ENV_URL/action_space?session_id=demo-s01"Close and retrieve final score plus trajectory:
curl -X POST "$ENV_URL/close" \
-H "Content-Type: application/json" \
-d '{"session_id":"demo-s01"}'Running With Your Own Model
This Space is the environment server. Your model can run anywhere as long as it can emit JSON tool calls and call the Space over HTTP.
The included inference.py runner supports two modes:
--api openai-local: call any OpenAI-compatible chat-completions server atINFERENCE_URL.--api local: load a local Hugging Face model through Transformers.
Example with an OpenAI-compatible local or remote inference server:
export ENV_URL="https://yatin-superintelligence-digital-hospital-environment.hf.space"
export INFERENCE_URL="http://localhost:8000"
python inference.py \
--api openai-local \
--model your-model-name \
--role S01 \
--env-url "$ENV_URL" \
--seed 42 \
--output results_S01.json \
--output-dir trajectories_demoThe inference server should implement:
POST /v1/chat/completions
GET /healthConcurrent Rollout Collection
For training data, use collect_rollouts.sh. It launches multiple isolated sessions concurrently by assigning a unique session_id to every run, then aggregates per-role JSON/parquet outputs.
export ENV_URL="https://yatin-superintelligence-digital-hospital-environment.hf.space"
export INFERENCE_URL="http://localhost:8000"
export MODEL="your-model-name"
export API="openai-local"
bash collect_rollouts.sh --iter 1 --runs 5 --seed 42Run only one role:
bash collect_rollouts.sh --iter 1 --runs 3 --roles S01Each rollout row contains the model-visible context, raw model output, parsed command and arguments, environment observation, reward, role metadata, and advantage signal. This is the stable interface for offline policy-improvement experiments.
Local Development
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn server.app:app --host 0.0.0.0 --port 7861Then open:
http://localhost:7861What The Environment Rewards
Digital Hospital rewards clinical process, not only final answers. Agents are evaluated on role-specific knowledge, patient triage, chart review, investigation, critical finding recognition, treatment-option review, safe treatment selection, research support, communication, director review, and reflection after feedback.
Correct treatment guesses without workup receive limited credit. Unsafe shortcuts, missing mandatory investigations, repeated tool calls, and unsupported treatment submissions are penalized. Hidden answer keys and process rubrics remain server-side.
