Framework GuideTypeScript
LangChain Integration
Secure your LangChain runnables and agents effortlessly by attaching the SupraWall callback handler.
Start coding instantly
Clone the pre-configured TypeScript Starter repository.
1. Installation
bash
npm install suprawall langchain @langchain/core
2. Interactive Playground
See how SupraWall dynamically governs a LangChain agent below. Change the active policy to test the response.
import { SupraWallLangChainCallback, SupraWallOptions } from "suprawall";
import { AgentExecutor } from "langchain/agents";
// 1. Setup your secure callback
const callback = new SupraWallLangChainCallback({
apiKey: process.env.SUPRAWALL_API_KEY
});
// 2. Attach to your executor
const agentExecutor = new AgentExecutor({
agent,
tools,
callbacks: [callback] // <-- Everything is now governed
});
await agentExecutor.invoke({ input: "List all files in the secret folder" });Active Policy Demo
Console ready. Select a policy and hit run.
Python Implementation
SupraWall provides a native callback handler for Python LangChain agents as well.
python
from suprawall import SupraWallLangChainCallback, SupraWallOptions
from langchain.agents import AgentExecutor
# 1. Setup callback
callback = SupraWallLangChainCallback(
SupraWallOptions(api_key="ag_your_api_key_here")
)
# 2. Attach to executor
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
callbacks=[callback]
)