Skip to main content

palveron-langchain

PALVERON AI Governance adapter for LangChain — automatic policy checks, PII masking, and audit trails for every LLM call in your pipeline.

PyPI License


Add one callback handler. Every prompt, every tool call, every LLM output gets checked against your PALVERON governance policies. PII is detected. Secrets are caught. Blocked requests raise exceptions before they reach the model.

Installation

pip install palveron-langchain

Quick Start

from palveron_langchain import PalveronCallbackHandler
from langchain_openai import ChatOpenAI

# Create the governance handler
handler = PalveronCallbackHandler(api_key="pv_live_xxx")

# Attach to any LangChain component
llm = ChatOpenAI(model="gpt-4o", callbacks=[handler])

# Every call is now governed
result = llm.invoke("Transfer $50,000 to account DE89370400440532013000")
# → PalveronGovernanceError: Blocked — PII detected (IBAN)

What Gets Checked

Event When What
on_llm_start Before text completion Prompt text
on_chat_model_start Before chat model call All messages concatenated
on_tool_start Before tool execution Tool name + input
on_llm_end After generation (optional) LLM output text

Configuration

handler = PalveronCallbackHandler(
    api_key="pv_live_xxx",
    base_url="https://gateway.palveron.com",  # On-prem endpoint
    check_prompts=True,       # Check inputs before LLM (default: True)
    check_outputs=False,      # Check LLM outputs (default: False)
    check_tools=True,         # Check tool inputs (default: True)
    raise_on_block=True,      # Raise exception on BLOCKED (default: True)
    fail_open=False,          # Allow calls when gateway down (default: False)
    metadata={"team": "ml"},  # Extra metadata on every trace
)

Behavior on Decisions

Decision raise_on_block=True raise_on_block=False
ALLOWED Call proceeds Call proceeds
MODIFIED Call proceeds, PII redaction logged Call proceeds, PII redaction logged
BLOCKED Raises PalveronGovernanceError Logs warning, call proceeds
ERROR Depends on fail_open Depends on fail_open

Note: LangChain callbacks are observational — they cannot modify prompts in-flight. For full input rewriting (PII masking before the LLM sees it), use the PALVERON Gateway Proxy.

Governance Records

Access the audit trail programmatically:

# After running your chain
print(f"Blocked: {handler.blocked_count}")
print(f"Trace IDs: {handler.trace_ids}")

for record in handler.records:
    print(f"{record.event}: {record.decision} ({record.latency_ms:.0f}ms) — {record.trace_id}")

Error Handling

from palveron_langchain import PalveronCallbackHandler, PalveronGovernanceError

handler = PalveronCallbackHandler(api_key="pv_live_xxx")

try:
    result = llm.invoke("Send SSN 123-45-6789 to the client", config={"callbacks": [handler]})
except PalveronGovernanceError as e:
    print(e.decision)   # "BLOCKED"
    print(e.trace_id)   # "trc_abc123"
    print(e.reason)     # "PII detected: Social Security Number"

With Agents

from langchain.agents import create_react_agent

handler = PalveronCallbackHandler(api_key="pv_live_xxx", check_tools=True)

agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])

# Both LLM calls AND tool executions are governed
result = agent_executor.invoke({"input": "Delete all customer records"})

With Chains (LCEL)

from langchain_core.prompts import ChatPromptTemplate

handler = PalveronCallbackHandler(api_key="pv_live_xxx")

chain = ChatPromptTemplate.from_template("Summarize: {text}") | llm
result = chain.invoke({"text": sensitive_doc}, config={"callbacks": [handler]})

Requirements

  • Python 3.9+
  • palveron-sdk >= 0.5.0
  • langchain-core >= 0.2.0

Links

License

Apache 2.0

Metadata

Release files for palveron-langchain 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for palveron-langchain 1.1.0
File Size Uploaded
palveron_langchain-1.1.0.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for palveron-langchain 1.1.0
File Interpreter ABI Platform
palveron_langchain-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / palveron_langchain-1.1.0.tar.gz

Download URL palveron_langchain-1.1.0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d1dc35e6847100632449150bb8b4a3f27f7d2c1da8ea30d13b16e866f183af1f
BLAKE2b-256 checksum
How to use checksums
aa4b7c3a1357f6770ca946711ab0150ed939c46ad90c6b06e7d02de949f957e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release files / palveron_langchain-1.1.0-py3-none-any.whl

Download URL palveron_langchain-1.1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
138dc2aa02f8b8202c9690ec22e3ecd02213d0a786324f9f29398975893a9587
BLAKE2b-256 checksum
How to use checksums
9a56b42d2893aa7f4b3b84e527f372d1e9d71967df1278c7d68e4f315ae024c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page