Monorepo containing a Python PII redaction library (privacy-filter) and agent framework integrations.
.
privacy-filter/ # Core library — PII detection/redaction
├── src/privacy_filter/
│ ├── __init__.py # Public API: get_classifier, redact_text, unredact_text, PiiStore
│ ├── pipeline.py # HuggingFace transformers pipeline loader (lazy, thread-safe singleton)
│ ├── redact.py # Entity merging, dedup, filtering, placeholder insertion
│ ├── unredact.py # Placeholder → original value restoration
│ └── types.py # PiiStore dataclass, ENTITY_SHORT_NAMES mapping
├── pyproject.toml # Package: privacy-filter
├── README.md # PyPI package documentation
└── uv.lock
nanobot-hook/ # NanoBot AgentHook integration
├── src/nanobot_hook/
│ ├── __init__.py # Exports PrivacyFilterHook
│ └── hook.py # AgentHook implementation
├── pyproject.toml # Package: nanobot-privacy-filter-hook
└── README.md # PyPI package documentation
openai-agents-hook/ # OpenAI Agents SDK guardrail integration
├── src/privacy_filter_openai/
│ ├── __init__.py # Exports PiiInputGuardrail, PiiOutputGuardrail
│ └── guardrails.py # Input/output guardrail implementations
├── pyproject.toml # Package: openai-agents-privacy-filter
└── README.md # PyPI package documentation
examples/
├── demo.py # Standalone demo (no external API needed)
├── server.py # End-to-end demo with OpenRouter LLM call
└── openai_agents_demo.py # OpenAI Agents SDK with guardrails
This repo uses uv for dependency management and hatchling for building.
Three separate packages are published:
privacy-filter— Core PII librarynanobot-privacy-filter-hook— NanoBot AgentHook integration (depends onprivacy-filter)openai-agents-privacy-filter— OpenAI Agents SDK guardrails (depends onprivacy-filter)
Publishing order matters: privacy-filter must be on PyPI before the integration packages can be built/published (because they declare privacy-filter as a dependency).
- Python 3.11+
uvinstalled (https://docs.astral.sh/uv/)- PyPI account with API token
# Work on privacy-filter package
cd privacy-filter
uv sync # Install deps from uv.lock
uv run python -c "from privacy_filter import get_classifier; print('OK')"Install packages as editable first:
uv pip install -e ./privacy-filter --system
uv pip install -e ./openai-agents-hook --system
uv pip install openai-agents --systemThen run with PYTHONPATH:
export PYTHONPATH="${PWD}/privacy-filter/src:${PWD}/openai-agents-hook/src"
export OPENROUTER_API_KEY=sk-or-v1-...
python examples/demo.py
python examples/server.py
python examples/openai_agents_demo.py# Build privacy-filter
cd privacy-filter
rm -rf dist/ # Clean old builds
uv build
# Outputs: dist/privacy_filter-*.whl and .tar.gz
# Build integration packages (privacy-filter must be installed first — use editable)
cd ../privacy-filter
uv pip install -e .
cd ../nanobot-hook
rm -rf dist/ # Clean old builds
uv build
cd ../openai-agents-hook
rm -rf dist/ # Clean old builds
uv buildNo GitHub Actions workflows exist. Publish manually:
# 1. Publish privacy-filter FIRST
cd privacy-filter
uv build
uv publish dist/*
# Or with twine: twine upload dist/*
# 2. Wait for PyPI to propagate, then publish integration packages
cd ../nanobot-hook
uv build
uv publish dist/*
cd ../openai-agents-hook
uv build
uv publish dist/*Important: If publishing integration packages fails because it can't find privacy-filter, wait a few minutes for PyPI index propagation or use --index-url with a local index.
cd privacy-filter
uv pip install -e . # Editable install
# Or from built wheel
uv pip install dist/privacy_filter-*.whl- privacy-filter:
transformers>=4.40.0,torch>=2.0.0 - nanobot-hook: depends on
privacy-filter, optionalnanobot-ai - openai-agents-hook: depends on
privacy-filter, optionalopenai-agents - examples: requires
openai,python-dotenv(install with--extra examples)
- Model download: First call to
get_classifier()downloads ~50MB from HuggingFace (cached to~/.cache/huggingface/orcache_dirif specified) - Thread-safety:
get_classifier()uses double-checked locking for singleton pipeline - Package path quirk:
pyproject.tomlusespackages = ["src/privacy_filter"]— this puts the package at root importprivacy_filter, notsrc.privacy_filter - Integration dependencies: All integration packages reference
"privacy-filter"in pyproject.toml — for local dev, install privacy-filter first (editable) before working on nanobot-hook or openai-agents-hook
# No formal test suite yet — verify with examples
cd privacy-filter
uv run python -c "
from privacy_filter import get_classifier, redact_text, unredact_text, PiiStore
store = PiiStore()
clf = get_classifier()
ents = clf('My email is test@example.com')
redacted = redact_text('My email is test@example.com', ents, store)
print('Redacted:', redacted)
print('Restored:', unredact_text(redacted, store))
"- privacy-filter/AGENTS.md — Core library details
- nanobot-hook/AGENTS.md — NanoBot integration details
- openai-agents-hook/AGENTS.md — OpenAI Agents SDK integration details