Skip to content

demos: add peyeeye PII redaction & rehydration filter chain#923

Open
tim-peyeeye wants to merge 1 commit intokatanemo:mainfrom
tim-peyeeye:tim/peyeeye-filter-chain
Open

demos: add peyeeye PII redaction & rehydration filter chain#923
tim-peyeeye wants to merge 1 commit intokatanemo:mainfrom
tim-peyeeye:tim/peyeeye-filter-chain

Conversation

@tim-peyeeye
Copy link
Copy Markdown

@tim-peyeeye tim-peyeeye commented Apr 26, 2026

Summary

Adds a new demos/filter_chains/peyeeye/ example, mirroring the existing pii_anonymizer demo. It's a FastAPI input/output filter pair that delegates PII detection to the Peyeeye API (https://api.peyeeye.ai) and rehydrates placeholders on the response path.

  • /redact/{path:path} redacts user text across chat completions, Anthropic messages, and Responses-API request bodies.
  • /rehydrate/{path:path} restores placeholders in the LLM response and best-effort deletes the stateful session.
  • Supports both stateful (default) and stateless (sealed skey_... blob) session modes via PEYEEYE_SESSION_MODE.

Fail-closed semantics

Any unexpected response shape from /v1/redact, or a length mismatch between sent and returned text counts, raises a 502 rather than forwarding partially-redacted data. Auth errors map to 500.

Tests

24 pytest cases covering the round trip, length-guard, unexpected-shape guard, multimodal content lists, Anthropic and Responses formats, and stateless mode. pre-commit run is clean.

cd demos/filter_chains/peyeeye
pytest -q

Files

  • peyeeye.py — FastAPI app with the two filter routes
  • config.yaml — plano filter-chain config wiring redact/rehydrate
  • Dockerfile, pyproject.toml, start_agents.sh, run_demo.sh, test.sh
  • README.md — setup + env-var reference (PEYEEYE_API_KEY, PEYEEYE_API_BASE, PEYEEYE_SESSION_MODE, PEYEEYE_LOCALE)
  • test_peyeeye.py — 24 pytest cases

Mirrors the pii_anonymizer demo: a FastAPI input/output filter pair that
delegates PII detection to the Peyeeye API (https://api.peyeeye.ai).

- /redact/{path:path}    redacts user text in chat completions, Anthropic
                          messages, and Responses-API request bodies.
- /rehydrate/{path:path} restores placeholders in the LLM response, then
                          best-effort deletes the stateful session.

Fail-closed semantics: any unexpected response shape from /v1/redact, or
a length mismatch between sent and returned text counts, raises a 502
rather than forwarding partially-redacted data. Auth errors map to 500.

Stateful (default) and stateless (sealed skey_... blob) session modes
are both supported via PEYEEYE_SESSION_MODE.

Includes 24 pytest cases covering the round trip, length-guard,
unexpected-shape guard, multimodal content lists, Anthropic and
Responses formats, and stateless mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant