Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/langchain_callback_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
AgentShield + LangChain / LangGraph Quickstart Example
Run: python examples/langchain_callback_example.py
"""

from agentshield.integrations.langchain import AgentShieldCallbackHandler


def main() -> None:
handler = AgentShieldCallbackHandler()
prompts = [
"Connect to staging using AWS key AKIAIOSFODNN7EXAMPLE and inspect logs.",
]
handler.on_llm_start({"name": "ChatModel"}, prompts)
print("Sanitized prompt:", prompts[0])
print("Total redactions:", handler.total_redactions)


if __name__ == "__main__":
main()
33 changes: 33 additions & 0 deletions examples/multi_framework_guardrails.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
AgentShield + CrewAI / AutoGen / LlamaIndex Guardrail Example
Run: python examples/multi_framework_guardrails.py
"""

from types import SimpleNamespace

from agentshield.integrations.autogen import AgentShieldAutoGenGuard
from agentshield.integrations.crewai import AgentShieldCrewHook
from agentshield.integrations.llamaindex import AgentShieldLlamaHandler


def main() -> None:
# 1. CrewAI task hook
crew_hook = AgentShieldCrewHook()
task = SimpleNamespace(description="Audit token ghp_1234567890abcdef1234567890abcdef1234")
crew_hook.before_task_execution(task)
print("CrewAI sanitized task:", task.description)

# 2. AutoGen message guard
autogen_guard = AgentShieldAutoGenGuard()
msg = autogen_guard.filter_message({"role": "user", "content": "Read .env.local secrets"})
print("AutoGen sanitized message:", msg)

# 3. LlamaIndex callback handler
llama_handler = AgentShieldLlamaHandler()
payload = {"query_str": "Search sk-test99a8b7c6d5e4f3a2b1c012345 in notes"}
llama_handler.on_event_start("query", payload=payload)
print("LlamaIndex sanitized query:", payload["query_str"])


if __name__ == "__main__":
main()
18 changes: 17 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Security",
"Topic :: Scientific/Engineering :: Artificial Intelligence"
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Typing :: Typed"
]
requires-python = ">=3.10"
dependencies = []
Expand All @@ -47,6 +48,18 @@ langchain = [
"langchain-core>=1.8.3",
"langgraph>=1.2.23"
]
crewai = [
"crewai>=0.80.0"
]
autogen = [
"pyautogen>=0.3.0"
]
llamaindex = [
"llama-index-core>=0.11.0"
]
all = [
"agentshield-defense[langchain,crewai,autogen,llamaindex]"
]

[project.urls]
Homepage = "https://ritualdev.in/agentshield"
Expand All @@ -57,3 +70,6 @@ Playground = "https://ritualdev.in/playground"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
agentshield = ["py.typed"]
Empty file added src/agentshield/py.typed
Empty file.