MCPcopy Index your code
hub / github.com/simstudioai/sim / anonymize_batch

Function anonymize_batch

apps/pii/server.py:288–298  ·  view source on GitHub ↗

Mask many texts in one pass, returning masked text per item in request order — the batched counterpart to /anonymize. Anonymization is pure string work (no NLP), so callers should send only items with detected spans.

(req: AnonymizeBatchRequest)

Source from the content-addressed store, hash-verified

286
287@app.post("/anonymize_batch")
288def anonymize_batch(req: AnonymizeBatchRequest) -> dict[str, list[str]]:
289 """Mask many texts in one pass, returning masked text per item in request
290 order — the batched counterpart to /anonymize. Anonymization is pure string
291 work (no NLP), so callers should send only items with detected spans."""
292 operators = build_operators(req.anonymizers or req.operators)
293 return {
294 "texts": [
295 run_anonymize(item.text, item.analyzer_results, operators).text
296 for item in req.items
297 ]
298 }

Callers

nothing calls this directly

Calls 2

build_operatorsFunction · 0.85
run_anonymizeFunction · 0.85

Tested by

no test coverage detected