CoolFace
Apppublic

prashant-9457/my-openenv-task

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

๐Ÿฅ ICU Resource Allocation โ€” OpenEnv

A real-world OpenEnv environment modelling a 20-bed ICU in a 500-bed Indian tertiary-care hospital. An AI agent acts as the ICU charge coordinator, making resource allocation decisions every 30 minutes over a 24-hour duty cycle.


๐ŸŒ Real-World Grounding

This environment is not a simulation of a game โ€” it models actual clinical practice:

ElementReal-World Source
SOFA scoring (0โ€“24)Vincent et al., JAMA 1996 โ€” gold-standard ICU triage
SOFA โ†’ mortalityFerreira et al., JAMA 2001
Nurse:patient ratioNABH ICU Standard (India) โ€” max 1:2
Bed turnover timesAgnihotri et al., Indian J Crit Care Med 2019
Arrival patternsArias-Verdรบ et al., Critical Care Medicine 2017
Cost calibrationCGHS ICU package rates 2023 (Central Govt Health Scheme)

๐ŸŽฎ Action Space (7 discrete actions)

#ActionEffectCost
0HOLDObserve, no changeโ‚น0
1ADMIT_CRITICALAdmit highest-SOFA patientโ€”
2ADMIT_FIFOAdmit longest-waiting patientโ€”
3TRANSFER_OUTMove stable patient to step-downโ€”
4CALL_EXTRA_NURSE+1 nurse, improves ratioโ‚น1,200
5SPECIALIST_CONSULTโˆ’15% mortality risk on sickest patientโ‚น3,500
6EXPEDITE_BEDFaster bed turnoverโ‚น600

๐Ÿ‘๏ธ Observation Space (27 fields)

Rich, clinically meaningful state:

  • โ€”Bed status: occupied / available / in turnover
  • โ€”Queue: total waiting, broken down by SOFA severity (critical/severe/moderate), longest wait
  • โ€”Patient acuity: avg SOFA score, avg mortality risk of current ICU patients
  • โ€”Equipment: ventilators & dialysis machines available/in-use
  • โ€”Staff: nurses on duty, nurse:patient ratio, doctors
  • โ€”Time: hour, shift (Day/Evening/Night), step
  • โ€”Budget: remaining INR, utilisation %
  • โ€”Outcomes: admissions, transfers, deaths in queue, adverse events, wait violations

๐Ÿ“‹ Tasks

๐ŸŸข Easy โ€” Prevent Preventable Deaths

Zero queue deaths + nurse:patient ratio โ‰ค 2.0 in โ‰ฅ90% of steps.

๐ŸŸก Medium โ€” NABH-Compliant Critical Care

All Easy criteria + all critical patients (SOFA โ‰ฅ 11) admitted within 2 hours of arrival. Maps to NABH Grade-B ICU standard.

๐Ÿ”ด Hard โ€” JCI-Grade ICU Excellence

All Medium criteria + zero adverse events + budget โ‰ค 85% + average SOFA non-increasing. Maps to JCI / NABH Grade-A accreditation benchmarks.


๐Ÿ”Œ API

bash
# Reset
curl -X POST http://localhost:7860/reset -H "Content-Type: application/json" -d '{"seed": 42}'

# Step (action 1 = ADMIT_CRITICAL)
curl -X POST http://localhost:7860/step -H "Content-Type: application/json" -d '{"action": 1}'

# State
curl http://localhost:7860/state

๐Ÿš€ Local Setup

bash
pip install -r requirements.txt

# Run server
python app.py

# Run graders (validates all scores in [0,1])
python graders/task_graders.py

# Run LLM inference (needs env vars)
export API_BASE_URL=...
export MODEL_NAME=...
export HF_TOKEN=...
python inference.py

๐Ÿ“ Structure

hospital_env/
โ”œโ”€โ”€ env.py                 # ICU environment (SOFA, NABH, Poisson arrivals)
โ”œโ”€โ”€ app.py                 # FastAPI: /reset /step /state
โ”œโ”€โ”€ inference.py           # LLM agent via OpenAI client
โ”œโ”€โ”€ openenv.yaml           # OpenEnv spec
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ graders/
    โ””โ”€โ”€ task_graders.py    # Easy / Medium / Hard graders โ†’ scores [0,1]