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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file noma_langchain_integration-0.1.1.tar.gz.
File metadata
- Download URL: noma_langchain_integration-0.1.1.tar.gz
- Upload date:
- Size: 95.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8a603b79b09db0b20775aad6ad5031e50d228aa5018881f1eacf2985bd90780
|
|
| MD5 |
933219d48ddeba6519f3cbe228663712
|
|
| BLAKE2b-256 |
918d5090acda10fceb5232ad1994e3f922eb339f10a2e87a62ec84aeb583561e
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noma_langchain_integration-0.1.1.tar.gz -
Subject digest:
d8a603b79b09db0b20775aad6ad5031e50d228aa5018881f1eacf2985bd90780 - Sigstore transparency entry: 1519211611
- Sigstore integration time:
-
Permalink:
Noma-Security/langchain-noma-integration-package@8235faa9c6dfaf01d8e570bc2d70ed93141043e2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Noma-Security
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@8235faa9c6dfaf01d8e570bc2d70ed93141043e2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file noma_langchain_integration-0.1.1-py3-none-any.whl.
File metadata
- Download URL: noma_langchain_integration-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65ac90e2f21b59caa8417704922f04836cd570fdf45707c3a3db9b4847bc38ae
|
|
| MD5 |
12eb6806a43041d0fc3f7a89c0002c8b
|
|
| BLAKE2b-256 |
5143b3fa42f226cb8095c1cb2ba20194b02e6560634a7bddb2860021994dc131
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noma_langchain_integration-0.1.1-py3-none-any.whl -
Subject digest:
65ac90e2f21b59caa8417704922f04836cd570fdf45707c3a3db9b4847bc38ae - Sigstore transparency entry: 1519211626
- Sigstore integration time:
-
Permalink:
Noma-Security/langchain-noma-integration-package@8235faa9c6dfaf01d8e570bc2d70ed93141043e2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Noma-Security
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@8235faa9c6dfaf01d8e570bc2d70ed93141043e2 -
Trigger Event:
push
-
Statement type: