¶ pilcrow-langchain
Deterministic compliance gate for LangChain pipelines.
Drop The Pilcrow into any LangChain chain with one line. Every LLM output is automatically linted before it reaches your users — no secondary LLM judge, no heuristics, pure deterministic logic.
pip install pilcrow-langchain
Quick Start
from langchain_openai import ChatOpenAI
from pilcrow_langchain import PilcrowCallbackHandler, PilcrowGovernanceError
handler = PilcrowCallbackHandler(api_key="pk_...")
llm = ChatOpenAI(model="gpt-4o")
try:
response = llm.invoke(
"Write a medical discharge summary for patient Jane Doe.",
config={"callbacks": [handler]},
)
print(response.content) # Compliant output
print(handler.last_result.audit_token) # Cryptographic attestation
except PilcrowGovernanceError as e:
print(f"REJECTED (score {e.score}/100)")
print("Repair guidance:")
for item in e.guidance:
print(f" — {item}")
Works with any LangChain chain
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from pilcrow_langchain import PilcrowCallbackHandler
handler = PilcrowCallbackHandler(api_key="pk_...")
chain = ChatPromptTemplate.from_template("{input}") | ChatOpenAI(model="gpt-4o")
# The handler lints every LLM output automatically
result = chain.invoke(
{"input": "Summarize this contract clause."},
config={"callbacks": [handler]},
)
Strict Mode
By default, REVIEW verdicts are allowed through. Enable strict=True to also block REVIEW:
handler = PilcrowCallbackHandler(api_key="pk_...", strict=True)
Inspecting the last result
handler.last_result always holds the full CheckResult from the most recent check:
result = handler.last_result
print(result.verdict) # "RELEASE" / "REVIEW" / "REJECT"
print(result.score) # 0–100
print(result.audit_token) # Cryptographic attestation
print(result.repair_guidance) # Deterministic fix instructions
for finding in result.findings:
print(f"[{finding.severity}] {finding.rule}: '{finding.matched}'")
Handling Governance Errors
from pilcrow_langchain import PilcrowGovernanceError
try:
response = llm.invoke("...", config={"callbacks": [handler]})
except PilcrowGovernanceError as e:
print(f"Verdict: {e.verdict}")
print(f"Score: {e.score}/100")
print(f"Audit token: {e.audit_token}")
print(f"Guidance: {e.guidance}")
# Route to human review, log to your audit system, alert your compliance team
Why a separate package?
pilcrow-langchain depends on langchain-core. Keeping it separate means:
- The core
pilcrowSDK stays lightweight — no LangChain dependencies for teams using raw HTTP or other frameworks. - LangChain updates frequently — the adapter can track it independently without touching your stable core SDK.
- Clean extensibility:
pilcrow-llamaindex,pilcrow-haystack, and others follow the same pattern.
Requirements
- Python 3.9+
pilcrow >= 1.0.0langchain-core >= 0.1.0
License
Proprietary. Copyright 2026 Abraham Chachamovits / ENTRUST AI. All rights reserved.
Metadata
Release files for pilcrow-langchain 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pilcrow_langchain-1.0.1.tar.gz | 5.2 kB | Without provenance | Details for pilcrow_langchain-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pilcrow_langchain-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for pilcrow_langchain-1.0.1-py3-none-any.whl |
Total release size: 11.3 kB
Release files / pilcrow_langchain-1.0.1.tar.gz
| Download URL | pilcrow_langchain-1.0.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
970f227d75166ce8fcc596aa18fcb42dcfaf954c6b0b4a25f6658cc9a311c0ff
|
|
BLAKE2b-256 checksum How to use checksums |
7e14a43113588f2f24aadff9b954ebd99dc6dfbc8b557355fcaae707abef974b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Release files / pilcrow_langchain-1.0.1-py3-none-any.whl
| Download URL | pilcrow_langchain-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c26d1fb2ffbb7f66a6da39a341f5b19a3cc8a56e0c9e738802f741acd335ae80
|
|
BLAKE2b-256 checksum How to use checksums |
5c9f8caeda358750e23418ad46275b4c92cff4d7247d2911555f2b28454f4a51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Security for pilcrow-langchain 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.