import { createStep } from "@mastra/core/workflows";
import { z } from "zod";
import { mastra } from "../mastra";
const agent = mastra.getAgent("productAgent");
const llmJsonStep = createStep({
id: "llm-json",
inputSchema: z.object({ prompt: z.string() }),
outputSchema: z.object({ name: z.string(), price: z.number() }),
async execute({ inputData }) {
const res = await agent.generate(
[{ role: "user", content: inputData.prompt }],
{ structuredOutput: { schema: this.outputSchema } }
);
return res.object; // validated result
},
});
import { createStep } from "@mastra/core/workflows";
import { z } from "zod";
import { mastra } from "../mastra";
const agent = mastra.getAgent("productAgent");
const llmJsonStep = createStep({
id: "llm-json",
inputSchema: z.object({ prompt: z.string() }),
outputSchema: z.object({ name: z.string(), price: z.number() }),
async execute({ inputData }) {
const res = await agent.generate(
[{ role: "user", content: inputData.prompt }],
{ structuredOutput: { schema: this.outputSchema } }
);
return res.object; // validated result
},
});