Build AI agents that execute actions to achieve goals
const calculatorAgent = createAgent({ instructions: `You are a calculator agent that helps users perform mathematical calculations.`, actions: [sum, minus], model: openai("gpt-4o"), });
export const sum = createAction({ id: "sum", description: "Adds two numbers together.", parameters: { type: "object", properties: { a: { type: "number", description: "First number to add" }, b: { type: "number", description: "Second number to add" }, }, required: ["a", "b"], }, async run({ parameters }): Promise<number> { const { a, b } = parameters || {}; return a + b; }, });