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 langchain_ledgerproof 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-1.0.1.tar.gz (19.6 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-1.0.1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for langchain_ledgerproof-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1eba4e7f0626227ae666e3a17881d228ab13b629593d0b32b0be4f7cab182585
MD5 d812801a75d2620d37483b9dd6a37852
BLAKE2b-256 df2d053a8d87ee7b5bc30f9059d051bd1dc443b7eb1ba2dd464efdc050e42d38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_ledgerproof-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aafac1875a709c1ab5c239612cc673b98c7a7e0ec1e2ac62c4da59e750944964
MD5 9590a77ed471b264a4ac0ba81b869438
BLAKE2b-256 3a1e4fe3f3a47c70616569ff2274e8c9883709d19a5f9258e41d6d15d16dda7b

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