langchain-aidr
CrowdStrike AIDR's tools for LangChain provide AI security features to protect your applications and data. Using these tools you can:
- Defend against prompt injection attacks.
- Prevent the exposure of sensitive information, including:
- Personally Identifiable Information (PII)
- Protected Health Information (PHI)
- Financial data
- Secrets
- Intellectual property
- Profanity
- Remove malicious content from inputs and outputs, such as IP addresses, domains, and URLs.
- Monitor user inputs and model responses to support threat analysis, auditing, and compliance efforts.
Installation
pip install -U langchain-aidr
Tools
One can run CrowdStrike AIDR tools using agents or invoke them as a Runnable
within chains.
AI Guard
import os
from langchain_aidr import CrowdStrikeAIGuard
from pydantic import SecretStr
aidr_token = SecretStr(os.getenv("CS_AIDR_TOKEN"))
aidr_base_url_template = SecretStr(os.getenv("CS_AIDR_BASE_URL_TEMPLATE"))
aidr_ai_guard_tool = CrowdStrikeAIGuard(token=aidr_token, base_url_template=aidr_base_url_template)
Agent
from langgraph.prebuilt import create_react_agent
from langchain_core.tools import tool
@tool
def search_tool(data):
"""Call to perform search"""
return """
47.84.32.175
37.44.238.68
47.84.73.221
47.236.252.254
34.201.186.27
52.89.173.88
"""
tools = [search_tool, aidr_ai_guard_tool]
query = """
Hi, I am Bond, James Bond. I monitor IPs found in MI6 network traffic.
Please find me the most recent ones, you copy?
"""
system_message="Always use AI Guard before your final response to keep it safe for the user."
langgraph_agent_executor = create_react_agent(model, tools, prompt=system_message)
state = langgraph_agent_executor.invoke({"messages": [("human", query)]})
Chain
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
prompt = ChatPromptTemplate.from_messages([("human", "{input}")])
query = """
Hi, I am Bond, James Bond. I am looking for a job. Please write me a super short resume.
I am skilled in international espionage, covert operations, and seduction.
Include a contact header:
Email: j.bond@mi6.co.uk
Phone: +44 20 0700 7007
Address: Universal Exports, 85 Albert Embankment, London, United Kingdom
"""
chain = (
prompt
| aidr_ai_guard_tool
| model
| StrOutputParser()
)
Standalone
aidr_ai_guard_tool.run("Spam me at example@example.com")
aidr_ai_guard_tool.invoke("Take my SSN: 234-56-7890")
Metadata
Release files for langchain-aidr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| langchain_aidr-0.1.0.tar.gz | 6.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_aidr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.7 kB
Release files / langchain_aidr-0.1.0.tar.gz
| Download URL | langchain_aidr-0.1.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7527925bb89b91c16e97cf8f158d17b52bf69a7d24aa251ebb72f3aaf2c25f81
|
|
BLAKE2b-256 checksum How to use checksums |
81c4f963e5c35fd730959dbe86ae70d6d8b0a95c585051a838061ec570fb3477
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 18, 2025.
Transparency logRelease files / langchain_aidr-0.1.0-py3-none-any.whl
| Download URL | langchain_aidr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1500f00dab7f1a15ed9ec304c81ca7c574129dbc98e926316f10206015a3d70f
|
|
BLAKE2b-256 checksum How to use checksums |
b94bf73fbc608d017dc65c1add3769b12e4ec834acb255f0c604c943f1fab174
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 18, 2025.
Transparency logSecurity for langchain-aidr 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for langchain_aidr-0.1.0.tar.gz
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 Dec 18, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.