Create file.js
Browse files
file.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
async function generateExpertCode(userProblem) {
|
| 2 |
+
const response = await fetch(
|
| 3 |
+
"https://api-inference.huggingface.co/models/deepseek-ai/deepseek-coder-1.3b-instruct", // موديل كود خفيف وقوي
|
| 4 |
+
{
|
| 5 |
+
headers: {
|
| 6 |
+
"Authorization": "Bearer YOUR_HUGGINGFACE_API_TOKEN",
|
| 7 |
+
"Content-Type": "application/json"
|
| 8 |
+
},
|
| 9 |
+
method: "POST",
|
| 10 |
+
body: JSON.stringify({
|
| 11 |
+
inputs: `System: You are an elite Senior Software Engineer. Follow the 5-step analysis/code protocol.\nUser: ${userProblem}\nAssistant:`,
|
| 12 |
+
parameters: {
|
| 13 |
+
max_new_tokens: 1024,
|
| 14 |
+
temperature: 0.2 // درجة حرارة منخفضة لضمان الدقة وعدم التأليف
|
| 15 |
+
}
|
| 16 |
+
}),
|
| 17 |
+
}
|
| 18 |
+
);
|
| 19 |
+
const result = await response.json();
|
| 20 |
+
return result;
|
| 21 |
+
}
|