import { Inviolet } from "@inviolet/sdk"
import OpenAI from "openai"
const inviolet = new Inviolet({ apiKey: process.env.INVIOLET_API_KEY! })
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY! })
const decision = await inviolet.intent.evaluate({
userId: "user_2pX9...",
toolCall: { name: "search_orders", arguments: { customer_id: "12345" } },
dataSourceId: "snowflake_prod",
})
if (decision.outcome === "denied") {
throw new Error(`call_denied: ${decision.intent_label}`)
}
const completion = await openai.chat.completions.create({
model: "gpt-4.1",
messages: [{ role: "user", content: "Find this customer's last 3 orders." }],
tools: [{ type: "function", function: { name: "search_orders" /* ... */ } }],
})