app.py) exposes /reset, /step, and /state endpoints that plug directly into the Space UI or custom agentsenvironment/data/protocols/ with per-task annotations used for scoringinference.py) that can call any OpenAI-compatible endpoint (Hugging Face Inference, OpenAI, local gateways, etc.)| Path | Purpose |
|---|---|
environment/env.py | Core ClinicalTrialEnv class, schemas, reward functions |
environment/data/protocols/ | JSON protocols with sections, dosage info, and contradictions |
app.py | FastAPI wiring for /reset, /step, /state |
server/app.py | Uvicorn entry point used by Docker/HF Space |
inference.py | Baseline agent loop + logging utilities |
Dockerfile | Minimal image that runs uvicorn app:app on port 7860 |
1python3 -m venv .venv && source .venv/bin/activate
2pip install -r requirements.txtuvicorn server.app:main --host 0.0.0.0 --port 7860ENV_URL=http://127.0.0.1:7860 (default) before running agents/tests.| Method | Path | Body | Response |
|---|---|---|---|
POST | /reset?task_id=1 | none | First observation for the requested task |
POST | /step | {action_type, target_section, issue_description, severity} | Next observation + reward, done, info.total_reward |
GET | /state | none | Internal simulator state (for debugging/visualization) |
1curl -X POST "http://localhost:7860/reset?task_id=2"
2curl -X POST http://localhost:7860/step \
3 -H "Content-Type: application/json" \
4 -d '{
5 "action_type": "flag_issue",
6 "target_section": "dosage",
7 "issue_description": "DrugY dosage is 2400mg/day, above the 2000mg/day limit.",
8 "severity": "high"
9 }'| Task ID | Focus | Success Criteria |
|---|---|---|
| 1 | Missing Section Detection | Flag every required protocol section that is absent, optionally approve sections that are present |
| 2 | Dosage Safety Compliance | Identify drug doses that exceed MAX_DRUG_DOSES in environment/data/rules.py and justify severity |
| 3 | Contradiction Detection | Point out conflicting statements between sections with references to both sides |
sections plus a ground_truth blob (missing sections, unsafe dosages, contradictions) that drives the reward.Observation model): trial_id, protocol_text, task_description, step_number, available_actionsAction model): JSON object with action_type (flag_issue, approve_section, recommend_amendment), target_section, issue_description, severityReward model): score in [0, 1], breakdown dict listing reward components, textual feedbackinference.py loops over the three tasks, logs every step, and prints a summary average. It talks to the environment via HTTP and to an OpenAI-compatible text model for decisions.ENV_URL.1export HF_TOKEN="hf_xxx" # required for Hugging Face text models
2export MODEL_NAME="Qwen/Qwen2.5-72B-Instruct" # or any compatible chat-completions model
3export API_BASE_URL="https://router.huggingface.co/v1" # defaults to OpenAI API
4export ENV_URL="https://clinical-trial-review.hf.space" # optional when running against the Spacepython inference.py to stream step-level logs and an overall average score. Logs follow the START/STEP/END pattern expected by OpenEnv submissions.sdk: docker with the provided Dockerfile. Any local change will be replicated by rebuilding and pushing the repo.1docker build -t clinical-trial-review .
2docker run -p 7860:7860 clinical-trial-reviewhttp://localhost:7860.1pip install -U "huggingface_hub[cli]"
2huggingface-cli loginORG/clinical-trial-review with your handle):
1huggingface-cli repo create ORG/clinical-trial-review \
2 --type space --space-sdk docker1git remote add hf https://huggingface.co/spaces/ORG/clinical-trial-review
2git push hf mainhf will trigger a rebuild using the bundled Dockerfile.inference.py to call hosted models:
HF_TOKEN – token with access to the selected text modelMODEL_NAME, API_BASE_URL, ENV_URL – override defaults consumed by inference.pyApplication running on 0.0.0.0:7860, the environment is live at https://ORG-clinical-trial-review.hf.space.openenv.yaml documents the task metadata consumed by the OpenEnv leaderboard.pyproject.toml exposes a server entry point (python -m server.app) if you prefer pip install . workflows.GET /state to inspect accumulated actions and rewards.