Skip to main content

LedgerProof adapter for LangChain and LangGraph. Emits EU AI Act Article 50 transparency receipts as a side channel.

Project description

ledgerproof-langchain

LangChain and LangGraph adapter for the LedgerProof protocol. Emits cryptographically signed transparency receipts as a side channel, suitable for evidence of EU AI Act Article 50 disclosure obligations.

Install

pip install ledgerproof-langchain
# Optional LangGraph support:
pip install "ledgerproof-langchain[langgraph]"

Python 3.10+.

5-minute quickstart (callback handler)

from langchain_openai import ChatOpenAI
from ledgerproof_langchain import LedgerProofCallbackHandler, LogEmitter

handler = LedgerProofCallbackHandler(
    deployer_id="acme-corp-eu",
    schema="chatbot_session/v1",
    emitter=LogEmitter("./receipts.jsonl"),
)

llm = ChatOpenAI(model="gpt-4o-mini", callbacks=[handler])
llm.invoke("Hello, are you an AI?")
# Receipt appended to ./receipts.jsonl. LLM response is not modified.

See examples/01_chatbot_quickstart.py and examples/02_langgraph_editorial.py.

What this adapter does

  • Captures a stream-aware SHA-256 transcript hash of the LLM interaction (commit-on-start, sign-on-end — never buffers the full body).
  • Signs the receipt with Ed25519.
  • Emits the receipt via a pluggable side channel (file, webhook, in-process queue).
  • Validates receipt structure against one of three Pydantic schemas:
    • chatbot_session/v1 (Article 50(1) — AI interaction disclosure)
    • generated_content/v1 (Article 50(2) — AI-generated content marking)
    • human_review/v1 (Article 50(4) — editorial-control exemption)
  • Supports both legacy LangChain callbacks and LangGraph node middleware.

What this adapter explicitly does NOT do

  • Does not modify the LLM response payload. Receipts are side-channel only.
  • Does not phone home during verification. Verification is offline against the Bitcoin chain and the published protocol public key.
  • Does not provide Article 9 (risk management), Article 10 (data governance), Article 13 (transparency to users beyond Article 50), Article 15 (accuracy / robustness / cybersecurity), or Article 72 (post-market monitoring) coverage.
  • Does not claim regulator endorsement.
  • Does not claim Article 40 presumption of conformity (no harmonized standard has been published for Article 50 at the time of this release).
  • Provides an Article 50 transparency receipt evidence layer only.

Schemas

All three schemas reject email-shaped strings in deployer_id, reviewer_role, and review_rationale fields as a GDPR safety check. Receipts should reference opaque pseudonymous identifiers, not personal data.

Phase 2+ roadmap

The MVP signer generates an ephemeral in-memory Ed25519 keypair. Production deployments will use HSM-backed signing (AWS KMS, GCP Cloud KMS, Azure Key Vault, YubiHSM). See signer.py for backend stubs.

License

Apache 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_ledgerproof-0.1.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_ledgerproof-0.1.1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_ledgerproof-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_ledgerproof-0.1.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for langchain_ledgerproof-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3c7a03e6116123620eb03e5e0a8bef0d5cd401dc8b42e2467a6825b1104aaaec
MD5 c56feae9773620af72d719dea9d66f3e
BLAKE2b-256 daa31c155924d592ad29d576ebedaccc18fdd383c7fdef73ed4e23cc9f1c0760

See more details on using hashes here.

File details

Details for the file langchain_ledgerproof-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_ledgerproof-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9eb6b856763a2d44087dbda63ae22c59f9a8ef0ee6a643c1faa7115acfaae15a
MD5 c9b03bbe584c21a595b19347fabad595
BLAKE2b-256 f34110eadb799ecfa81de40f1ee2f01f42f723135665b83d430307884337ee78

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page