franisman commited on
Commit
4bbb6c5
·
verified ·
1 Parent(s): 89504e8

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +59 -0
index.html ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ar" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Llama 3 Chat Space</title>
6
+ <style>
7
+ body { background: #000; color: #0f0; text-align: center; font-family: sans-serif; padding: 20px; }
8
+ .container { border: 2px solid #0f0; padding: 20px; border-radius: 15px; max-width: 600px; margin: auto; }
9
+ textarea { width: 90%; height: 120px; background: #111; color: #fff; border: 1px solid #0f0; padding: 10px; border-radius: 8px; margin-bottom: 10px; }
10
+ button { width: 95%; padding: 15px; background: #0f0; color: #000; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; }
11
+ #response { margin-top: 20px; background: #1a1a1a; padding: 15px; border-radius: 10px; min-height: 50px; text-align: right; line-height: 1.6; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+
16
+ <div class="container">
17
+ <h2>دردشة Llama 3 - Space الخاص بك</h2>
18
+ <textarea id="userInput" placeholder="اسألني أي شيء بالعربي أو الإنجليزي..."></textarea>
19
+ <button onclick="askAI()">إرسال السؤال</button>
20
+ <div id="response">بانتظار سؤالك...</div>
21
+ </div>
22
+
23
+ <script>
24
+ const API_TOKEN = "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";
25
+
26
+ async function askAI() {
27
+ const input = document.getElementById('userInput').value;
28
+ const resDiv = document.getElementById('response');
29
+
30
+ if(!input) return alert("اكتب شيئاً أولاً");
31
+ resDiv.innerText = "جاري التفكير... انتظر قليلاً";
32
+
33
+ try {
34
+ const response = await fetch(
35
+ "https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-3B-Instruct",
36
+ {
37
+ headers: {
38
+ "Authorization": `Bearer ${API_TOKEN}`,
39
+ "Content-Type": "application/json"
40
+ },
41
+ method: "POST",
42
+ body: JSON.stringify({ inputs: input }),
43
+ }
44
+ );
45
+
46
+ const result = await response.json();
47
+ if (response.ok) {
48
+ // عرض النتيجة
49
+ resDiv.innerText = result[0].generated_text || "انتهى التفكير!";
50
+ } else {
51
+ resDiv.innerText = "خطأ من السيرفر: " + (result.error || "تأكد من الموافقة على شروط الموديل");
52
+ }
53
+ } catch (e) {
54
+ resDiv.innerText = "فشل الاتصال: " + e.message;
55
+ }
56
+ }
57
+ </script>
58
+ </body>
59
+ </html>