Skip to main content

Noma guardrail middleware integration for LangChain

Project description

noma-langchain-integration

Noma guardrail middleware for LangChain agents. Scans user and assistant messages to detect and handle unsafe content before and after agent execution.

Installation

pip install noma-langchain-integration

Quick start

from langchain.agents import create_agent
from langchain_noma.middleware import NomaGuardrailMiddleware

middleware = NomaGuardrailMiddleware(
    api_key="noma-...",  # or set NOMA_API_KEY env var
)

agent = create_agent(
    model="openai:gpt-4.1",
    tools=[...],
    middleware=[middleware],
)

The middleware runs two hooks automatically:

  • before_agent — scans user messages before the agent processes them.
  • after_agent — scans assistant messages after the agent responds.

Both sync and async hooks are supported (abefore_agent, aafter_agent).

Configuration

All parameters are optional and keyword-only:

Parameter Type Default Description
api_key str | None NOMA_API_KEY env API key for the Noma service. Required when using the Noma SaaS endpoint.
application_id str | None NOMA_APPLICATION_ID env or "langchain" Application identifier sent with each scan request.
block_failures bool True When True (fail-closed), block requests if the AIDR API is unreachable. When False (fail-open), allow requests through on scan failure.

Environment variables

Variable Required Description
NOMA_API_KEY Yes (SaaS) API key. Can also be passed via the api_key constructor parameter.
NOMA_APPLICATION_ID No Override the application identifier (defaults to "langchain").

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

noma_langchain_integration-0.1.1.tar.gz (95.9 kB view details)

Uploaded Source

Built Distribution

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

noma_langchain_integration-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for noma_langchain_integration-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d8a603b79b09db0b20775aad6ad5031e50d228aa5018881f1eacf2985bd90780
MD5 933219d48ddeba6519f3cbe228663712
BLAKE2b-256 918d5090acda10fceb5232ad1994e3f922eb339f10a2e87a62ec84aeb583561e

See more details on using hashes here.

Provenance

The following attestation bundles were made for noma_langchain_integration-0.1.1.tar.gz:

Publisher: publish_pypi.yml on Noma-Security/langchain-noma-integration-package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for noma_langchain_integration-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65ac90e2f21b59caa8417704922f04836cd570fdf45707c3a3db9b4847bc38ae
MD5 12eb6806a43041d0fc3f7a89c0002c8b
BLAKE2b-256 5143b3fa42f226cb8095c1cb2ba20194b02e6560634a7bddb2860021994dc131

See more details on using hashes here.

Provenance

The following attestation bundles were made for noma_langchain_integration-0.1.1-py3-none-any.whl:

Publisher: publish_pypi.yml on Noma-Security/langchain-noma-integration-package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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