Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_aidr-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

langchain_aidr-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

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

Hashes for langchain_aidr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7527925bb89b91c16e97cf8f158d17b52bf69a7d24aa251ebb72f3aaf2c25f81
MD5 53eac1e403b4e4ee584b0225f11d19d3
BLAKE2b-256 81c4f963e5c35fd730959dbe86ae70d6d8b0a95c585051a838061ec570fb3477

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_aidr-0.1.0.tar.gz:

Publisher: publish.yml on CrowdStrike/langchain-aidr

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

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

Hashes for langchain_aidr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1500f00dab7f1a15ed9ec304c81ca7c574129dbc98e926316f10206015a3d70f
MD5 f47e4ca7a898eb146109ac687dd156a7
BLAKE2b-256 b94bf73fbc608d017dc65c1add3769b12e4ec834acb255f0c604c943f1fab174

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_aidr-0.1.0-py3-none-any.whl:

Publisher: publish.yml on CrowdStrike/langchain-aidr

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