tools في generateText لتنفيذ الدوال بمعلمات محددة الأنواع.
ملاحظات
- اجعل أوصاف الأدوات دقيقة ومعلماتها صارمة.
- تحقّق من الآثار الجانبية الخارجية داخل
execute. - أضف إعادة المحاولة والانتظار التصاعدي لواجهات أدوات المراحل اللاحقة عند الحاجة.
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
استدعاء الدوال والأدوات باستخدام Vercel AI SDK ومزوّد Phaseo.
tools في generateText لتنفيذ الدوال بمعلمات محددة الأنواع.
import { phaseo } from "@phaseo/ai-sdk-provider";
import { generateText } from "ai";
import { z } from "zod";
const result = await generateText({
model: phaseo("openai/gpt-5-nano"),
prompt: "What is 17 + 25? Use the calculator tool.",
tools: {
calculator: {
description: "Perform basic arithmetic",
parameters: z.object({
operation: z.enum(["add", "subtract", "multiply", "divide"]),
a: z.number(),
b: z.number(),
}),
execute: async ({ operation, a, b }) => {
if (operation === "add") return a + b;
if (operation === "subtract") return a - b;
if (operation === "multiply") return a * b;
return a / b;
},
},
},
});
console.log(result.text);
execute.هل كانت هذه الصفحة مفيدة؟