MCPcopy
hub / github.com/simstudioai/sim / anonymize

Function anonymize

apps/pii/server.py:262–284  ·  view source on GitHub ↗
(req: AnonymizeRequest)

Source from the content-addressed store, hash-verified

260
261@app.post("/anonymize")
262def anonymize(req: AnonymizeRequest) -> dict[str, Any]:
263 started = time.perf_counter()
264 operators = build_operators(req.anonymizers or req.operators)
265 result = run_anonymize(req.text, req.analyzer_results, operators)
266 logger.info(
267 "anonymize chars=%d spans=%d duration_ms=%.1f",
268 len(req.text),
269 len(req.analyzer_results),
270 (time.perf_counter() - started) * 1000,
271 )
272 return {
273 "text": result.text,
274 "items": [
275 {
276 "operator": item.operator,
277 "entity_type": item.entity_type,
278 "start": item.start,
279 "end": item.end,
280 "text": item.text,
281 }
282 for item in result.items
283 ],
284 }
285
286
287@app.post("/anonymize_batch")

Callers

nothing calls this directly

Calls 3

build_operatorsFunction · 0.85
run_anonymizeFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected