PIIGhost
piighost is a Python library that keeps PII (personally identifiable information) from reaching a language model, while keeping the application fully functional.
The library spots PII with detectors (regex, NER, or another LLM) and replaces each value with a stable placeholder, for example john.doe@example.com becomes <<EMAIL:1>>. The model only ever works on de-identified text. When the LLM returns placeholders, piighost puts the real values back in place, the end user sees john.doe@example.com and never notices the de-identification. The same mechanism protects tool-using agents. A tool that needs the real address receives it in clear, while the LLM that decides to call it still sees only <<EMAIL:1>>.
Finally, the library keeps the mapping between a value and its placeholder across the whole conversation. If john.doe@example.com shows up again three messages later, the placeholder stays <<EMAIL:1>>, so the model can follow the thread.
The LLM only sees placeholders. The tool receives the real address, the user gets a clear-text reply, and your agent code stays the same.
[!NOTE]
piighostperforms reversible de-identification. Because the mapping between a value and its placeholder is kept so the data can be restored, this is pseudonymisation under the GDPR, not permanent anonymisation. The real values stay stored for the duration of the conversation and must be protected accordingly.
Quickstart
uv add piighost
De-identify a text
ExactMatchDetector de-identifies a dictionary of known values without downloading a model.
import asyncio
from piighost.components.detector import ExactMatchDetector
from piighost.pipeline import AnonymizationPipeline
detector = ExactMatchDetector({"John Doe": "PERSON", "john.doe@example.com": "EMAIL"})
pipeline = AnonymizationPipeline(detector)
result = asyncio.run(pipeline.anonymize("Write to John Doe at john.doe@example.com."))
print(result.text) # Write to <<PERSON:1>> at <<EMAIL:1>>.
Conversations and agents (LangChain)
The middleware wraps a conversational pipeline and handles each agent turn. The LLM only sees placeholders, tools receive the real values, the user gets a clear-text reply.
uv add 'piighost[middleware]'
from langchain.agents import create_agent
from piighost.integrations.middleware import PIIAnonymizationMiddleware
# pipeline: a ThreadAnonymizationPipeline, see the conversation guide
agent = create_agent(
model="openai:gpt-5.4",
tools=[send_email],
middleware=[PIIAnonymizationMiddleware(pipeline=pipeline)],
)
For a real detector, the conversational pipeline and a full LangChain example, see the Quickstart and the LangChain integration.
Documentation
- Get started
- How-to
- Reference
- Concepts
Project
- Contributing: contribution guide and report a bug
- Ecosystem:
- Presentation site: an overview of the project
- piighost-api: the inference API server
- piighost-chat: an example chat interface with human-in-the-loop
- License: MIT
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 piighost-1.0.1.tar.gz.
File metadata
- Download URL: piighost-1.0.1.tar.gz
- Upload date:
- Size: 2.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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 |
fbc66f454aee34d7e4eebdcd13dab8b24b92780a3b741b6316c1f86ad08716fa
|
|
| MD5 |
9f99138e4b8241798f8c975df1a6d839
|
|
| BLAKE2b-256 |
af08a462c96654fe2a0ecee425f1fcc31833de80f038c67ad6755cdb6ad93777
|
File details
Details for the file piighost-1.0.1-py3-none-any.whl.
File metadata
- Download URL: piighost-1.0.1-py3-none-any.whl
- Upload date:
- Size: 120.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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 |
b7261070c7ab47e5ae4b9e0e142e60cab684a8ddb07e796866434e1e7ef6323a
|
|
| MD5 |
6789c7fc18bb76496e8ea1ebee7869d4
|
|
| BLAKE2b-256 |
caff3b8322808fd8572fe468ae3be9f45caef2d6b4ac68f0b34eb0aeab9717b7
|