본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)5.8k · #14733

serving-openmed-rest-api

하는 일

이 스킬은 다른 프로그램이 웹으로 호출할 수 있는 의료 텍스트 분석 서비스를 실행하는 방법을 에이전트에게 가르칩니다. 개인 정보를 찾아 가리는 내부 서비스를 원하는 팀을 위한 스킬입니다.

사용하는 경우

  • ✓의료 용어를 찾는 비공개 내부 웹 서비스를 원하는 팀일 때.
  • ✓다른 앱이 HTTP로 호출할 수 있는 비식별화 경로가 필요한 개발자일 때.
  • ✓배포를 위해 서비스를 컨테이너로 묶고 싶을 때.

스킬 링크

https://github.com/maziyarpanahi/openmed/blob/master/skills/serving-openmed-rest-api/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/maziyarpanahi/openmed/blob/master/skills/serving-openmed-rest-api/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“우리 앱들이 노트에서 환자 이름을 제거하도록 호출할 수 있는 내부 웹 서비스를 설정하도록 도와주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 FastAPI 서비스를 설치하고 실행한 뒤, analyze와 deidentify 같은 경로를 추가합니다. 스킬은 이 서비스가 자체 호스팅이며 모델은 기기에서 실행된다고 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Serving OpenMed over REST

openmed.service is a hardened FastAPI app exposing OpenMed's NER, PII extraction, and de-identification over HTTP. It is built to be self-hosted: models run on-device, there's no telemetry, and the request schemas reject raw PHI from spilling into errors. Use it when callers need request/response inference; use batch-processing-clinical-text for corpora.

When to use this skill

To put OpenMed behind an HTTP endpoint your own apps call — an internal de-id microservice, an NER backend, a containerized inference tier. For agent/tool integration prefer the MCP server (deploying-openmed-mcp); for offline bulk work use batch processing.

Quick start

pip install "openmed[service]"          # FastAPI + uvicorn + pydantic

# Launch the ASGI app (factory create_app, or the module-level `app`)
python -m openmed.service.logging --host 127.0.0.1 --port 8000
# Or build it in-process (e.g. to mount under a parent app / add middleware):
from openmed.service import create_app
app = create_app()
curl -s localhost:8000/health
# {"status":"ok","service":"openmed-rest","version":"...","profile":"prod"}

curl -s localhost:8000/analyze -H 'content-type: application/json' -d '{
  "text": "Patient received 75mg clopidogrel for NSTEMI.",
  "model_name": "disease_detection_superclinical"
}'

curl -s localhost:8000/pii/deidentify -H 'content-type: application/json' -d '{
  "text": "John Doe called 555-123-4567 on 01/15/2020.",
  "method": "mask"
}'

Endpoints (confirmed in openmed/service/app.py)

Method & path Purpose Request schema
GET /health liveness + version + active profile —
GET /models/loaded cache/keep-alive status of resident models —
POST /models/unload unload one model or all inactive models ModelUnloadRequest (model_name or all=true)
POST /analyze clinical NER AnalyzeRequest
POST /pii/extract detect PII/PHI spans PIIExtractRequest
POST /pii/deidentify mask/remove/replace/hash/shift-dates PHI PIIDeidentifyRequest

Request fields (from openmed/service/schemas.py, strict — unknown fields are rejected):

  • AnalyzeRequest: text (required), model_name ("disease_detection_superclinical"), confidence_threshold (0.0), group_entities, aggregation_strategy (simple|first|average|max), sentence_detection, sentence_language, sentence_clean, use_fast_tokenizer, keep_alive.
  • PIIExtractRequest: text, model_name (default OpenMed/OpenMed-PII-SuperClinical-Small-44M-v1), confidence_threshold (0.5), use_smart_merging, lang (en/fr/de/it/es/nl/hi/te/pt/ar/ja/tr), normalize_accents, keep_alive.
  • PIIDeidentifyRequest: same base plus method (mask|remove|replace|hash|shift_dates, default mask), confidence_threshold (0.7), keep_year, shift_dates, date_shift_days, keep_mapping, policy, use_smart_merging, use_safety_sweep.

Responses are the OpenMed result to_dict() (e.g. {text, entities[...], ...}). Errors use a stable envelope: {"error": {"code", "message", "details"}} with 422 validation_error, 400 bad_request, 504 timeout, 500 internal_error.

Configuring the runtime (env vars)

ServiceRuntime.from_env() reads the process environment at startup (openmed/service/runtime.py):

Env var Effect
OPENMED_PROFILE config profile (prod default)
OPENMED_SERVICE_PRELOAD_MODELS comma list of models to warm at startup
OPENMED_SERVICE_KEEP_ALIVE default idle keep-alive before unload
OPENMED_SERVICE_MAX_RESIDENT_MODELS cap resident models (warm pool)
OPENMED_SERVICE_BATCHING_ENABLED enable dynamic request batching
OPENMED_SERVICE_BATCH_MAX_SIZE max dynamic batch size (default 8)
OPENMED_SERVICE_BATCH_MAX_WAIT_MS batch-collection window (default 5ms)
OPENMED_SERVICE_PRELOAD_MODELS="disease_detection_superclinical" \
OPENMED_SERVICE_BATCHING_ENABLED=true \
python -m openmed.service.logging --host 0.0.0.0 --port 8000

Preloading avoids first-request latency; the warm pool keeps hot models resident and idle-unloads the rest. /analyze and /pii/extract coalesce concurrent requests when batching is enabled.

Workflow

  1. Install + launch. pip install "openmed[service]", then run python -m openmed.service.logging (or build with create_app()).
  2. **Config
자주 묻는 질문

서비스가 데이터를 다른 곳으로 보내나요?

스킬은 원격 측정 데이터가 없고 모델은 기기에서 실행된다고 설명합니다.

상태 확인 기능이 있나요?

네. 서비스 상태를 보고하는 health 엔드포인트를 보여 줍니다.

많은 문서를 한 번에 처리하려면요?

대규모 모음은 별도의 일괄 처리 스킬을 사용하라고 안내합니다.

상세 정보

작성자의 원본 설명

Stand up OpenMed's FastAPI REST service for clinical NER, PII extraction, and de-identification, with health checks, model keep-alive/unload, optional dynamic batching, and no-PHI logging. Use when the user wants to serve OpenMed over HTTP, deploy a de-id/NER REST API, run an inference endpoint for clinical text, add a /analyze or /pii/deidentify route, or containerize OpenMed as a service. Covers the service extra, launching create_app with uvicorn, the real endpoints (/health, /analyze, /pii/extract, /pii/deidentify, /models/loaded, /models/unload), request/response shapes, ServiceRuntime en

repo: maziyarpanahi/openmed

인기도

GitHub 스타
5.8k
순위
#14733
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬