import { Output } from "@ai_kit/core/agents";
import { z } from "zod";
const personSpec = Output.object({
schema: z.object({
name: z.string(),
age: z.number().nullable().describe("Âge de la personne."),
contact: z.object({
type: z.literal("email"),
value: z.string(),
}),
occupation: z.object({
type: z.literal("employed"),
company: z.string(),
position: z.string(),
}),
}),
});
const structured = await assistant.generate({
prompt: "Crée un profil de test pour un client potentiel.",
structuredOutput: personSpec,
});
console.log(structured.experimental_output);
// -> { name: "...", age: 32, contact: { ... }, occupation: { ... } }