-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-builder.js
More file actions
66 lines (54 loc) · 2.28 KB
/
ai-builder.js
File metadata and controls
66 lines (54 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const { execSync } = require("child_process");
const fs = require("fs");
// البرومبت المطور: يختبر قدرة الذكاء الاصطناعي على بناء نظام SaaS كامل
const PROMPT = `
اكتب JSON فقط فقط فقط.
ممنوع أي شرح.
ممنوع أي نص خارج JSON.
ابنِ نظام SaaS متكامل لشركة توصيل (Delivery SaaS) يتضمن:
1. عنوان ووصف احترافي.
2. قائمة خدمات متطورة.
3. خطط أسعار (Basic, Pro).
4. 3 اقتراحات ذكية لتطوير العمل.
5. كلمة مفتاحية لصورة HD من Unsplash.
{
"title": "اسم البراند",
"description": "وصف تسويقي عميق",
"services": [
{ "t": "خدمة 1", "d": "شرح" }
],
"pricing": [
{ "plan": "الخطة", "price": "السعر" }
],
"suggestions": ["اقتراح 1", "اقتراح 2"],
"imgKeyword": "business delivery technology"
}
`;
console.log("🚀 جاري فحص العقل الذكي (Ollama) بأوامر SaaS...");
try {
const output = execSync(
`ollama run qwen2.5:7b "${PROMPT.replace(/"/g, '\\"')}"`,
{ encoding: "utf8" }
);
// حفظ المخرجات الخام للفحص
fs.writeFileSync("raw_output.json", output, "utf8");
const start = output.indexOf("{");
const end = output.lastIndexOf("}");
if (start === -1 || end === -1) {
console.error("❌ خطأ: الذكاء الاصطناعي لم يرجع JSON صحيح");
process.exit(1);
}
const jsonText = output.slice(start, end + 1);
const finalData = JSON.parse(jsonText);
console.log("✅ تم التوليد بنجاح! النتيجة فخمة:");
console.log("------------------------------------");
console.log("عنوان الموقع:", finalData.title);
console.log("عدد الاقتراحات الذكية:", finalData.suggestions.length);
console.log("كلمة الصورة:", finalData.imgKeyword);
console.log("------------------------------------");
// حفظ النتيجة النظيفة
fs.writeFileSync("clean_test.json", JSON.stringify(finalData, null, 2), "utf8");
console.log("📁 تم حفظ النتيجة النظيفة في clean_test.json");
} catch (error) {
console.error("❌ حدث خطأ أثناء الاتصال بـ Ollama:", error.message);
}