نادراً ما يكون لسؤال بحثي مصدر واحد. ما العواصم الأوروبية التي غيّرت هذا العام قواعد الإيجار قصير الأجل، وكيف؟ يحتاج الأمر إلى بحث وقراءة متأنية لصفحات كثيرة وملاحظة التناقضات وكتابة ملخص يوضح مصادر الوقائع. يناسب ذلك Gemini 4 Argon؛ ويربطه هذا الدليل بوكيل محلي يستخدم البحث وجلب الصفحات ويحفظ مذكرة.
أنشئ وكيل البحث
يحصل الوكيل على الأدوات اللازمة فقط: البحث للعثور على المصادر، و`fetch` لقراءتها، و`write` لحفظ المذكرة، و`todo_write` للتخطيط. تستهلك عمليات البحث وقراءة الصفحات أرصدة، لذا يحدد التشغيل بميزانية وعدد خطوات.
import { IaGenify } from "iagenify";
const api = new IaGenify({ apiKey: process.env.IAGENIFY_API_KEY });
const pc = await api.storage.get();
const agent = api.agents.create({
runtime: "local",
machine: pc,
model: "gemini-4-argon",
tools: ["search", "fetch", "write", "todo_write"],
mode: "auto",
budget: 150,
maxSteps: 40,
system: "You are a careful researcher. Every factual sentence in your memo cites the URL you read it on. Say when sources disagree.",
});
const result = await agent.run({
message: "Research which European capitals changed their short-term rental rules in 2026. Read at least eight official or primary sources. Write the memo to Research/rentals-2026.md with a sources section.",
});
console.log(result.usage.credits, result.stopReason);حوّل المذكرة إلى بيانات
المذكرة موجهة للأشخاص. ويستخرج استدعاء ثانٍ ذو مخطط محدد النتائج بصيغة JSON: مدخل لكل مدينة مع المصدر الذي يدعمها.
const memo = await pc.files.read("Research/rentals-2026.md");
const extractor = await api.models.create({
model: "gemini-4-argon",
memory: false,
schema: {
type: "object",
properties: {
cities: {
type: "array",
items: {
type: "object",
properties: {
city: { type: "string" },
change: { type: "string", description: "What changed, in one sentence" },
effective: { type: "string", description: "ISO 8601 date, or empty if unknown" },
source: { type: "string", description: "The URL this finding relies on" },
},
required: ["city", "change", "source"],
},
},
},
required: ["cities"],
},
});
const { outputs } = await extractor.generate({ inputs: [{ type: "text", content: memo.content }] });
console.log(outputs[0].content.cities);تحقق قبل النشر
يسهل التحقق من المذكرة الموثقة، لكن ذلك لا يعني أنها تحققت تلقائياً. افتح المصادر التي تعتمد عليها واترك مسؤولية الاستنتاج لشخص.
المراجع
الأسئلة الشائعة
لماذا وكيل بدلاً من تعليمات طويلة واحدة؟
لأن المصادر غير معروفة مسبقاً؛ يبحث الوكيل ويقرأ ما يجده ويقرر ما ينبغي قراءته تالياً.
ما الحد الأقصى لإنفاق التشغيل؟
لا يتجاوز الميزانية المحددة، وهي 150 رصيداً في المثال. يتوقف قبل تجاوزها ويذكر ذلك في `stopReason`.