File size: 594 Bytes
6dec997 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import { z } from "zod";
import { generateContract, staticModel } from "@krishthesmart/contract-kit";
const UserProfile = z.object({
name: z.string(),
role: z.string(),
risk: z.enum(["low", "medium", "high"])
});
const result = await generateContract({
model: staticModel([
JSON.stringify({
name: "Priya Shah",
role: "Security Engineering Manager",
risk: "medium"
})
]),
schema: UserProfile,
prompt: "Extract the user's profile from the support ticket.",
retries: 2,
onEvent(event) {
console.log(event.type);
}
});
console.log(result.data);
|