LangChain integrations for CrowdStrike AIDR
Project description
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")
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 langchain_aidr-0.1.0.tar.gz.
File metadata
- Download URL: langchain_aidr-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7527925bb89b91c16e97cf8f158d17b52bf69a7d24aa251ebb72f3aaf2c25f81
|
|
| MD5 |
53eac1e403b4e4ee584b0225f11d19d3
|
|
| BLAKE2b-256 |
81c4f963e5c35fd730959dbe86ae70d6d8b0a95c585051a838061ec570fb3477
|
Provenance
The following attestation bundles were made for langchain_aidr-0.1.0.tar.gz:
Publisher:
publish.yml on CrowdStrike/langchain-aidr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_aidr-0.1.0.tar.gz -
Subject digest:
7527925bb89b91c16e97cf8f158d17b52bf69a7d24aa251ebb72f3aaf2c25f81 - Sigstore transparency entry: 771257009
- Sigstore integration time:
-
Permalink:
CrowdStrike/langchain-aidr@1e91488675da4eb0704a89a7a892f51ea2d2b37b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/CrowdStrike
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e91488675da4eb0704a89a7a892f51ea2d2b37b -
Trigger Event:
release
-
Statement type:
File details
Details for the file langchain_aidr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_aidr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1500f00dab7f1a15ed9ec304c81ca7c574129dbc98e926316f10206015a3d70f
|
|
| MD5 |
f47e4ca7a898eb146109ac687dd156a7
|
|
| BLAKE2b-256 |
b94bf73fbc608d017dc65c1add3769b12e4ec834acb255f0c604c943f1fab174
|
Provenance
The following attestation bundles were made for langchain_aidr-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on CrowdStrike/langchain-aidr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_aidr-0.1.0-py3-none-any.whl -
Subject digest:
1500f00dab7f1a15ed9ec304c81ca7c574129dbc98e926316f10206015a3d70f - Sigstore transparency entry: 771257020
- Sigstore integration time:
-
Permalink:
CrowdStrike/langchain-aidr@1e91488675da4eb0704a89a7a892f51ea2d2b37b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/CrowdStrike
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e91488675da4eb0704a89a7a892f51ea2d2b37b -
Trigger Event:
release
-
Statement type: