Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +3 -3
- PROJECT_SUMMARY.md +43 -0
- README.md +1 -1
- requirements.txt +6 -0
- server/app.py +2 -2
Dockerfile
CHANGED
|
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# Install Python dependencies
|
| 14 |
-
COPY
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
# Copy environment code
|
|
@@ -25,8 +25,8 @@ ENV PYTHONPATH="/app:$PYTHONPATH"
|
|
| 25 |
|
| 26 |
# Health check
|
| 27 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 28 |
-
CMD curl -f http://localhost:
|
| 29 |
|
| 30 |
# Run the FastAPI server
|
| 31 |
ENV ENABLE_WEB_INTERFACE=true
|
| 32 |
-
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "
|
|
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# Install Python dependencies
|
| 14 |
+
COPY requirements.txt .
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
# Copy environment code
|
|
|
|
| 25 |
|
| 26 |
# Health check
|
| 27 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 28 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 29 |
|
| 30 |
# Run the FastAPI server
|
| 31 |
ENV ENABLE_WEB_INTERFACE=true
|
| 32 |
+
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]
|
PROJECT_SUMMARY.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Project Summary: MedTriage OpenEnv
|
| 2 |
+
**Meta PyTorch OpenEnv Hackathon Submission**
|
| 3 |
+
|
| 4 |
+
## 🏥 Project Overview
|
| 5 |
+
**MedTriage** is a real-world simulation environment designed for training and evaluating AI agents in clinical decision-making. Unlike "toy" environments, it models a genuine human task: categorizing patient symptoms into appropriate care levels (Self-Care, Clinic, Urgent Care, or Emergency).
|
| 6 |
+
|
| 7 |
+
## 🛠️ What We Built
|
| 8 |
+
We have developed a complete, spec-compliant OpenEnv environment with the following components:
|
| 9 |
+
|
| 10 |
+
### 1. Core Environment (`server/triage_environment.py`)
|
| 11 |
+
- **Action Space**: A `triage_patient` tool where agents assign a triage level (0-3) and provide clinical reasoning.
|
| 12 |
+
- **Observation Space**: Detailed patient profiles including demographics, unstructured symptom text, vitals (BP, Temp, HR, SpO2), and medical history.
|
| 13 |
+
- **Reward Function**: A medical-safety-first scoring system (0.0 - 1.0) that rewards accuracy and penalizes dangerous under-triage (e.g., missing an emergency).
|
| 14 |
+
|
| 15 |
+
### 2. Mandatory Tasks
|
| 16 |
+
Implemented three specific scenarios with automated graders:
|
| 17 |
+
- **TASK_EASY**: Seasonal Allergies (Self-Care)
|
| 18 |
+
- **TASK_MEDIUM**: Possible Appendicitis (Urgent Care)
|
| 19 |
+
- **TASK_HARD**: Atypical Myocardial Infarction in elderly patient (Emergency)
|
| 20 |
+
|
| 21 |
+
### 3. API Infrastructure (`server/app.py`)
|
| 22 |
+
- Implemented standard OpenEnv endpoints: `/reset`, `/step`, `/state`.
|
| 23 |
+
- Added required Hackathon endpoints:
|
| 24 |
+
- `/tasks`: Dynamic list of available scenarios and schemas.
|
| 25 |
+
- `/grader`: Real-time performance scoring.
|
| 26 |
+
- `/baseline`: Automated trigger for the inference script.
|
| 27 |
+
|
| 28 |
+
### 4. Baseline Inference (`inference.py`)
|
| 29 |
+
- Created a reproducible baseline script that uses medical heuristics to evaluate the environment. It ensures the environment is "solveable" and provides a benchmark score for comparison.
|
| 30 |
+
|
| 31 |
+
## 🚀 Technical Improvements & Fixes
|
| 32 |
+
To ensure the project meets the highest submission standards, we performed the following:
|
| 33 |
+
- **Spec Compliance**: Added missing `__init__.py` files and standardized the directory structure to pass `openenv validate`.
|
| 34 |
+
- **Dependency Management**: Updated `pyproject.toml` and `server/requirements.txt` to include `openenv-core>=0.2.0` and generated a `uv.lock` file.
|
| 35 |
+
- **Containerization**: Optimized the `Dockerfile` to support root-level builds, enabled health checks, and added editable installation (`pip install -e .`) to resolve local module imports.
|
| 36 |
+
- **Deployment Automation**: Configured `README.md` with Hugging Face Space metadata (`app_port: 8002`, `sdk: docker`) for seamless hosting.
|
| 37 |
+
|
| 38 |
+
## 🌐 Deployment Links
|
| 39 |
+
- **GitHub Repository**: [https://github.com/ash399/med-triage-openenv](https://github.com/ash399/med-triage-openenv)
|
| 40 |
+
- **Hugging Face Space**: [https://huggingface.co/spaces/ashdev/med-triage-openenv](https://huggingface.co/spaces/ashdev/med-triage-openenv)
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
*Documented on: Monday, March 30, 2026*
|
README.md
CHANGED
|
@@ -3,7 +3,7 @@ title: MedTriage OpenEnv
|
|
| 3 |
emoji: 🏥
|
| 4 |
sdk: docker
|
| 5 |
pinned: false
|
| 6 |
-
app_port:
|
| 7 |
tags:
|
| 8 |
- openenv
|
| 9 |
- healthcare
|
|
|
|
| 3 |
emoji: 🏥
|
| 4 |
sdk: docker
|
| 5 |
pinned: false
|
| 6 |
+
app_port: 7860
|
| 7 |
tags:
|
| 8 |
- openenv
|
| 9 |
- healthcare
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
pydantic
|
| 4 |
+
fastmcp
|
| 5 |
+
requests
|
| 6 |
+
openenv-core>=0.2.0
|
server/app.py
CHANGED
|
@@ -68,7 +68,7 @@ async def trigger_baseline():
|
|
| 68 |
from inference import run_baseline
|
| 69 |
|
| 70 |
# Execute actual baseline
|
| 71 |
-
scores = run_baseline(base_url="http://localhost:
|
| 72 |
|
| 73 |
return {
|
| 74 |
"status": "baseline_completed",
|
|
@@ -77,7 +77,7 @@ async def trigger_baseline():
|
|
| 77 |
|
| 78 |
def main():
|
| 79 |
import uvicorn
|
| 80 |
-
uvicorn.run(app, host="0.0.0.0", port=
|
| 81 |
|
| 82 |
if __name__ == "__main__":
|
| 83 |
main()
|
|
|
|
| 68 |
from inference import run_baseline
|
| 69 |
|
| 70 |
# Execute actual baseline
|
| 71 |
+
scores = run_baseline(base_url="http://localhost:7860")
|
| 72 |
|
| 73 |
return {
|
| 74 |
"status": "baseline_completed",
|
|
|
|
| 77 |
|
| 78 |
def main():
|
| 79 |
import uvicorn
|
| 80 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 81 |
|
| 82 |
if __name__ == "__main__":
|
| 83 |
main()
|