Pular para o conteúdo
Skillpedia
APIs e servidores (backend)5,8 mil · #14733

serving-openmed-rest-api

O que ela faz

Esta skill ensina um agente a rodar um serviço de análise de texto médico que outros programas podem chamar pela web. É para equipes que querem um serviço interno para encontrar e mascarar dados pessoais.

Quando usar

  • ✓Quando uma equipe quer um serviço web interno e privado que encontre termos médicos em textos.
  • ✓Quando um desenvolvedor precisa de uma rota de desidentificação que outros apps possam chamar por HTTP.
  • ✓Quando um usuário quer empacotar o serviço em um contêiner para implantação.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/maziyarpanahi/openmed/blob/master/skills/serving-openmed-rest-api/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Me ajude a montar um serviço web interno que os nossos apps possam chamar para remover nomes de pacientes das notas.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente instala o serviço FastAPI, o inicia e adiciona rotas como analyze e deidentify. A skill informa que o serviço é hospedado pelo próprio usuário e que seus modelos rodam no dispositivo.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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
Perguntas frequentes

O serviço envia dados para outro lugar?

A skill afirma que não há telemetria e que os modelos rodam no dispositivo.

Existe verificação de saúde?

Sim. A skill mostra um endpoint de saúde que informa o status do serviço.

Devo usar isto para muitos documentos de uma vez?

A skill indica uma skill separada de processamento em lote para grandes coleções.

Detalhes

Descrição original do autor

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

Popularidade

Estrelas no GitHub
5,8 mil
Posição no ranking
#14733
Licença
Apache-2.0
Atualizada em
02/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas