FastAPI and Ray Serve app for openai/privacy-filter.
The service loads the Hugging Face token-classification model in a Ray Serve actor, finds PII spans, and can return either spans only or masked text.
make setupThis creates .venv/, installs dependencies with uv, and installs the local pre-commit hooks.
make serveThe service listens on 0.0.0.0:8080 by default. Override with HOST or PORT:
PORT=8000 make serveRay Serve import path for charts or serveConfig:
privacy_filter.service:deployment
make docker-build
make docker-runEquivalent commands:
docker build -t privacy-filter:local .
docker run --rm -p 8080:8080 privacy-filter:localMODEL_ID changes the model loaded by the Serve actor. It defaults to openai/privacy-filter.
MASTER_KEY sets the API key required by POST /privacy-filter.
MASTER_KEY=sk-default MODEL_ID=openai/privacy-filter make serveHealth checks:
curl http://localhost:8080/healthz
curl http://localhost:8080/readyzFilter text:
curl -X POST http://localhost:8080/privacy-filter \
-H "content-type: application/json" \
-H "x-pf-api-key: $MASTER_KEY" \
-d '{
"items": ["Email jane@example.com or call 555-0100."],
"mask": true,
"threshold": 0.5
}'POST /privacy-filter requires the x-pf-api-key header. Its value must match the
service MASTER_KEY environment variable. Health check endpoints do not require
an API key.
Response shape:
{
"results": [
{
"masked_text": "Email [EMAIL] or call [PHONE].",
"spans": [
{
"category": "email",
"text": "jane@example.com",
"start": 6,
"end": 22,
"score": 0.99
}
]
}
],
"model_id": "openai/privacy-filter",
"num_items": 1
}Swagger UI is available at http://localhost:8080/docs when the service is running.
make test
make lint