集成
LangChain, CrewAI and LlamaIndex
Drop-in zn guards for popular Python agent frameworks.
本页尚未翻译,当前显示英文版本。
The adapters ship with the Python package (pip install zn-gate) under zn_gate.integrations. They use local rules by default and the cloud model when ZN_API_KEY is set.
LangChain and LangGraph
A callback handler checks prompts and tool inputs as the agent runs:
from zn_gate.integrations import ZnGuardCallbackHandler
handler = ZnGuardCallbackHandler(raise_on_injection=True)
agent = initialize_agent(tools, llm, callbacks=[handler])
CrewAI
Wrap a tool function so blocked calls return a fallback instead of executing:
from zn_gate.integrations import guarded_tool
@guarded_tool(on_block="return", fallback="BLOCKED_BY_GUARD", mask_secrets=True)
def run_search(query: str):
return search_api(query)
LlamaIndex
Check a query before it reaches the index:
from zn_gate.integrations import ZnLlamaGuard
guard = ZnLlamaGuard(raise_on_violation=True)
safe_query = guard.on_query_start(user_query)
Not using a framework? See the SDK.