llmfy-guardrails is a standalone text-based PII detector/masker (PIIGuard, PIIType, PIIStrategy, PIIDetection/PIIDetectionResult). It has no dependency on llmfy or any other LLM framework — drop it into any Python pipeline that needs to detect or mask PII in plain text.
How to install
# Using UV
uv add llmfy-guardrails
# Using pip
pip install llmfy-guardrails
Installing llmfy-guardrails pulls in pydantic automatically — nothing else.
PII Guard — PERSON_NAME / ADDRESS detection
Most PIITypes are regex-based and work with no extra install. PIIType.PERSON_NAME/PIIType.ADDRESS are the exception — they're backed by an optional spaCy NER model, loaded lazily on first use:
# Using UV
uv add "llmfy-guardrails[spacy]"
uv add https://github.com/irufano/spacy_ner_pii/releases/download/v0.1.0/xx_ent_pii_sm-0.1.0-py3-none-any.whl
# Using pip
pip install "llmfy-guardrails[spacy]"
pip install https://github.com/irufano/spacy_ner_pii/releases/download/v0.1.0/xx_ent_pii_sm-0.1.0-py3-none-any.whl
xx_ent_pii_sm isn't published to PyPI, so it can't be pulled in as a normal extra — install it manually from the release wheel above.
Note that PIIGuard() defaults to detecting every PIIType, including these two — pass exclude_types=[PIIType.PERSON_NAME, PIIType.ADDRESS] if you don't want this dependency.
How to use
from llmfy_guardrails import PIIGuard, PIIStrategy, PIIType
guard = PIIGuard(exclude_types=[PIIType.PERSON_NAME, PIIType.ADDRESS]) # strategy=TOKENIZE (default)
result = guard.detect("Contact john.doe@example.com or call (555) 123-4567.")
print(result.processed_text) # "Contact [EMAIL_1] or call [PHONE_NUMBER_1]."
restored = guard.restore(result.processed_text, result.detections)
print(restored) # "Contact john.doe@example.com or call (555) 123-4567."
See llmfy_guardrails/example/pii_example.py for a full walkthrough of every strategy (TOKENIZE, MASK, REDACT, PARTIAL), custom types, and the NER-backed types.
Contributing
See CONTRIBUTING.md for commit message format, the automatic version-bump/release process, and local package development commands.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmfy_guardrails-0.1.1.tar.gz.
File metadata
- Download URL: llmfy_guardrails-0.1.1.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fab951eca3e8df352cdc676052061f4b04804517496f4c1646f00a67c15b267
|
|
| MD5 |
f51dd2abbebdc3e467356b01fd88a1e9
|
|
| BLAKE2b-256 |
8e7ee259fc0cce64a7636ae485a4f0b6e1e2df0ca7d6da19ec150acb77aa7f7e
|
File details
Details for the file llmfy_guardrails-0.1.1-py3-none-any.whl.
File metadata
- Download URL: llmfy_guardrails-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7366d21cc499b8607e4e1e0dd4a03486a90a8087c43544d609d24b06d1ac3842
|
|
| MD5 |
32d2ab6b2550f114824ebab293be2fb6
|
|
| BLAKE2b-256 |
6ef0dbc35afc4e4089d2bbd7622021b45185375cdf4870a48721c81e754216be
|