Skip to content

Commit b6fbe9a

Browse files
feat(phase5): add py.typed, crewai/autogen/llamaindex extras, and runnable examples
1 parent b61a75f commit b6fbe9a

4 files changed

Lines changed: 70 additions & 1 deletion

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
AgentShield + LangChain / LangGraph Quickstart Example
3+
Run: python examples/langchain_callback_example.py
4+
"""
5+
6+
from agentshield.integrations.langchain import AgentShieldCallbackHandler
7+
8+
9+
def main() -> None:
10+
handler = AgentShieldCallbackHandler()
11+
prompts = [
12+
"Connect to staging using AWS key AKIAIOSFODNN7EXAMPLE and inspect logs.",
13+
]
14+
handler.on_llm_start({"name": "ChatModel"}, prompts)
15+
print("Sanitized prompt:", prompts[0])
16+
print("Total redactions:", handler.total_redactions)
17+
18+
19+
if __name__ == "__main__":
20+
main()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
AgentShield + CrewAI / AutoGen / LlamaIndex Guardrail Example
3+
Run: python examples/multi_framework_guardrails.py
4+
"""
5+
6+
from types import SimpleNamespace
7+
8+
from agentshield.integrations.autogen import AgentShieldAutoGenGuard
9+
from agentshield.integrations.crewai import AgentShieldCrewHook
10+
from agentshield.integrations.llamaindex import AgentShieldLlamaHandler
11+
12+
13+
def main() -> None:
14+
# 1. CrewAI task hook
15+
crew_hook = AgentShieldCrewHook()
16+
task = SimpleNamespace(description="Audit token ghp_1234567890abcdef1234567890abcdef1234")
17+
crew_hook.before_task_execution(task)
18+
print("CrewAI sanitized task:", task.description)
19+
20+
# 2. AutoGen message guard
21+
autogen_guard = AgentShieldAutoGenGuard()
22+
msg = autogen_guard.filter_message({"role": "user", "content": "Read .env.local secrets"})
23+
print("AutoGen sanitized message:", msg)
24+
25+
# 3. LlamaIndex callback handler
26+
llama_handler = AgentShieldLlamaHandler()
27+
payload = {"query_str": "Search sk-test99a8b7c6d5e4f3a2b1c012345 in notes"}
28+
llama_handler.on_event_start("query", payload=payload)
29+
print("LlamaIndex sanitized query:", payload["query_str"])
30+
31+
32+
if __name__ == "__main__":
33+
main()

‎pyproject.toml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ classifiers = [
3232
"Programming Language :: Python :: 3.12",
3333
"Programming Language :: Python :: 3.13",
3434
"Topic :: Security",
35-
"Topic :: Scientific/Engineering :: Artificial Intelligence"
35+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
36+
"Typing :: Typed"
3637
]
3738
requires-python = ">=3.10"
3839
dependencies = []
@@ -47,6 +48,18 @@ langchain = [
4748
"langchain-core>=1.8.3",
4849
"langgraph>=1.2.23"
4950
]
51+
crewai = [
52+
"crewai>=0.80.0"
53+
]
54+
autogen = [
55+
"pyautogen>=0.3.0"
56+
]
57+
llamaindex = [
58+
"llama-index-core>=0.11.0"
59+
]
60+
all = [
61+
"agentshield-defense[langchain,crewai,autogen,llamaindex]"
62+
]
5063

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

5871
[tool.setuptools.packages.find]
5972
where = ["src"]
73+
74+
[tool.setuptools.package-data]
75+
agentshield = ["py.typed"]

‎src/agentshield/py.typed‎

Whitespace-only changes.

0 commit comments

Comments
 (0)