nanobot-privacy-filter-hook
PII redaction guardrail for NanoBot. Automatically redact personally identifiable information before LLM calls and restore original values in responses.
Features
- Automatic PII detection — Uses the
openai/privacy-filtermodel locally - Pre/post processing — Redact before LLM sees text, unredact in the response
- Message format support — Works with string and OpenAI vision-style list content
- Configurable — Adjust confidence thresholds and filter by entity type
Installation
pip install nanobot-privacy-filter-hook
Requires:
- Python 3.11+
nanobot-ai(for AgentHook interface)
Quick Start
from nanobot_hook import PrivacyFilterHook
# Create hook
hook = PrivacyFilterHook(min_score=0.8)
# Register with NanoBot's CompositeHook
from nanobot.agent.hook import CompositeHook
composite = CompositeHook([hook, other_hook])
# Pass composite to your NanoBot agent runner
How It Works
before_iteration()— Creates a freshPiiStore, redacts all text content in user/system messagesfinalize_content()— Restores original values from placeholders in the LLM response
Configuration
from nanobot_hook import PrivacyFilterHook
hook = PrivacyFilterHook(
min_score=0.8, # Minimum confidence threshold (0.0-1.0)
entity_types=None, # Filter to specific entities (None = all)
cache_dir=None, # Custom HuggingFace cache directory
)
Supported Entity Types
| Entity | Placeholder | Description |
|---|---|---|
private_email |
[EMAIL_N] |
Email addresses |
private_person |
[PERSON_N] |
Person names |
private_phone |
[PHONE_N] |
Phone numbers |
private_address |
[ADDRESS_N] |
Physical addresses |
private_url |
[URL_N] |
URLs |
private_date |
[DATE_N] |
Dates |
account_number |
[ACCOUNT_N] |
Account numbers |
secret |
[SECRET_N] |
Passwords, API keys |
Example: Full Integration
from nanobot.agent.hook import CompositeHook, AgentHookContext
from nanobot_hook import PrivacyFilterHook
# Create and register hook
pii_hook = PrivacyFilterHook(min_score=0.9)
composite = CompositeHook([pii_hook])
# The hook automatically processes messages before each LLM iteration
# and unredacts content before returning to the user
Dependencies
privacy-filter— Core PII detection librarynanobot-ai(optional extra) — NanoBot AgentHook framework
Related
- Core library: privacy-filter
- OpenAI Agents integration: openai-agents-privacy-filter
License
MIT
Metadata
Release files for nanobot-privacy-filter-hook 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nanobot_privacy_filter_hook-0.1.0.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nanobot_privacy_filter_hook-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / nanobot_privacy_filter_hook-0.1.0.tar.gz
| Download URL | nanobot_privacy_filter_hook-0.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55046690120650b5a47c03b6e71dd3db7c817ffc34ae552dbbe42a1fa16aeab7
|
|
BLAKE2b-256 checksum How to use checksums |
25c7cf32d91c1bbcee621e22dab7a4a7aac00d9b60b77445f2a9621b31458058
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nanobot_privacy_filter_hook-0.1.0-py3-none-any.whl
| Download URL | nanobot_privacy_filter_hook-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
751778d27bd51cf91dafdd6479c3d63eb0f51df0500474e7ad03db8ada3f4215
|
|
BLAKE2b-256 checksum How to use checksums |
bf05b7345b3129ee90d829c073211d98b56be4813b511f9b3b65cf60b6f92083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|