|
1 | | -# editor |
| 1 | +--- |
| 2 | +title: Open Syndrome Editor |
| 3 | +emoji: 🩺 |
| 4 | +colorFrom: green |
| 5 | +colorTo: blue |
| 6 | +sdk: docker |
| 7 | +app_port: 7860 |
| 8 | +pinned: false |
| 9 | +--- |
| 10 | + |
| 11 | +# Open Syndrome Definition — Editor |
| 12 | + |
| 13 | +A web editor for [Open Syndrome Definitions (OSD)](https://github.com/OpenSyndrome/schema): |
| 14 | +write a free-text clinical case definition and **convert** it to machine-readable JSON, |
| 15 | +**validate** it against the schema, **enrich** ontology IDs via EBI OLS4, and |
| 16 | +**humanize** JSON back into narrative text — all powered by the |
| 17 | +[`opensyndrome`](https://github.com/OpenSyndrome/open-syndrome-python) Python package. |
| 18 | + |
| 19 | +It pairs a two-pane "clinical IDE" UI (React + Vite) with a FastAPI backend, served |
| 20 | +together as a single container on [Hugging Face Spaces](https://huggingface.co/spaces). |
| 21 | + |
| 22 | +## Features |
| 23 | + |
| 24 | +- **Convert** — parse free clinical text into the OSD schema (LLM via the configured provider). |
| 25 | +- **Validate** — check a definition against the downloaded OSD JSON Schema. |
| 26 | +- **Enrich** — populate `ontology_id`s by matching criterion names through EBI OLS4. |
| 27 | +- **Humanize** — regenerate narrative text from the structured definition. |
| 28 | +- **Import** — clinical text, a local JSON file, or browse the community |
| 29 | + [definitions repo](https://github.com/OpenSyndrome/definitions). |
| 30 | +- Recursive **inclusion / exclusion** criteria trees (AND / OR / AT_LEAST), full metadata, |
| 31 | + live validation, View / Copy / Download JSON. |
| 32 | + |
| 33 | +## Models (convert & humanize) |
| 34 | + |
| 35 | +The LLM provider/model is configurable via environment variables (see `.env.example`): |
| 36 | + |
| 37 | +```bash |
| 38 | +OPENSYNDROME_PROVIDER=huggingface # default in the container |
| 39 | +OPENSYNDROME_MODEL=... # a model served by HF Inference Providers |
| 40 | +HF_TOKEN=... # auto-injected on Hugging Face Spaces |
| 41 | +``` |
| 42 | + |
| 43 | +`validate` and `enrich` need no LLM (enrich only calls EBI OLS4). |
| 44 | + |
| 45 | +## Run locally |
| 46 | + |
| 47 | +**Dev mode (recommended — reads your `.env`, simplest for ollama):** |
| 48 | + |
| 49 | +```bash |
| 50 | +cp .env.example .env # set OPENSYNDROME_PROVIDER / OPENSYNDROME_MODEL |
| 51 | +uv sync |
| 52 | +uv run uvicorn app.main:app --reload --port 8000 # API on :8000 |
| 53 | + |
| 54 | +cd frontend && npm install && npm run dev # UI on :5173 (proxies /api -> :8000) |
| 55 | +# open http://localhost:5173 |
| 56 | +``` |
| 57 | + |
| 58 | +With `OPENSYNDROME_PROVIDER=ollama`, this talks to ollama on `localhost:11434` directly. |
| 59 | +Make sure the model is pulled: `ollama pull qwen2.5:7b-instruct`. |
| 60 | + |
| 61 | +**Single production image (what ships to HF Spaces):** |
| 62 | + |
| 63 | +```bash |
| 64 | +docker build -t opensyndrome-editor . |
| 65 | + |
| 66 | +docker run --rm -p 7860:7860 opensyndrome-editor |
| 67 | + |
| 68 | +# convert/humanize need a provider. Pass your .env: |
| 69 | +docker run --rm -p 7860:7860 --env-file .env opensyndrome-editor |
| 70 | +``` |
| 71 | + |
| 72 | +**ollama from Docker**: ollama runs on the host, so point the container at it with `OLLAMA_HOST`: |
| 73 | + |
| 74 | +```bash |
| 75 | +docker run --rm -p 7860:7860 \ |
| 76 | + --add-host=host.docker.internal:host-gateway \ |
| 77 | + -e OPENSYNDROME_PROVIDER=ollama \ |
| 78 | + -e OPENSYNDROME_MODEL=qwen2.5:7b-instruct \ |
| 79 | + -e OLLAMA_HOST=http://host.docker.internal:11434 \ |
| 80 | + opensyndrome-editor |
| 81 | +# open http://localhost:7860 |
| 82 | +``` |
| 83 | + |
| 84 | +On **Hugging Face Spaces**, set `OPENSYNDROME_PROVIDER`, `OPENSYNDROME_MODEL` (and any key) |
| 85 | +as Space *variables/secrets* — `HF_TOKEN` is injected automatically. |
| 86 | + |
| 87 | +## Tests |
| 88 | + |
| 89 | +```bash |
| 90 | +uv run pytest # backend API |
| 91 | +cd frontend && npm test # frontend logic (osd.js) |
| 92 | +``` |
| 93 | + |
| 94 | +## Deploy |
| 95 | + |
| 96 | +Hosted on Hugging Face Spaces (Docker SDK). Pushes to `main` are mirrored to the Space |
| 97 | +by the `Sync to Hugging Face hub` GitHub Action. |
0 commit comments