Spaces:
Running
Running
Download index.html from sadik1111/model_projct: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/spaces/sadik1111/model_projct/resolve/main/index.html
- Command line
-
hf download hf://spaces/sadik1111/model_projct/index.html
-
curl -L -o index.html https://huggingface.co/spaces/sadik1111/model_projct/resolve/main/index.html
3.15 kB
| <html lang="ar" dir="rtl"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Gemma API Connector</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; max-width: 600px; margin: 40px auto; padding: 20px; } | |
| input[type="password"], textarea { width: 100%; margin-bottom: 15px; padding: 10px; box-sizing: border-box; } | |
| textarea { height: 100px; } | |
| button { padding: 10px 20px; background-color: #ffd21e; border: none; font-weight: bold; cursor: pointer; width: 100%; } | |
| #output { margin-top: 20px; padding: 15px; background: #f4f4f4; border-radius: 5px; white-space: pre-wrap; } | |
| </style> | |
| </head> | |
| <body> | |
| <h2>مساعد Gemma</h2> | |
| <label>رمز الوصول (Access Token):</label> | |
| <input type="password" id="tokenInput" placeholder="أدخل رمز hf_... الخاص بك هنا"> | |
| <label>النص (Prompt):</label> | |
| <textarea id="promptInput" placeholder="أدخل نصاً هنا..."></textarea> | |
| <button onclick="generateText()">إرسال</button> | |
| <h3>النتيجة:</h3> | |
| <div id="output">بانتظار الإدخال...</div> | |
| <script> | |
| async function generateText() { | |
| const token = document.getElementById("tokenInput").value.trim(); | |
| const prompt = document.getElementById("promptInput").value; | |
| const outputDiv = document.getElementById("output"); | |
| if (!token) { | |
| outputDiv.innerText = "يرجى إدخال Access Token أولاً."; | |
| return; | |
| } | |
| outputDiv.innerText = "جاري الاتصال بالنموذج..."; | |
| try { | |
| // استخدام الرابط الحديث لمعالجة الطلبات | |
| const response = await fetch("https://router.huggingface.co/hf-inference/v1/chat/completions", { | |
| method: "POST", | |
| headers: { | |
| "Authorization": `Bearer ${token}`, | |
| "Content-Type": "application/json" | |
| }, | |
| body: JSON.stringify({ | |
| model: "google/gemma-2b-it", | |
| messages: [{ role: "user", content: prompt }], | |
| max_tokens: 200 | |
| }) | |
| }); | |
| const data = await response.json(); | |
| if (data.error) { | |
| outputDiv.innerText = "خطأ من السيرفر: " + JSON.stringify(data.error); | |
| } else if (data.choices && data.choices[0]) { | |
| outputDiv.innerText = data.choices[0].message.content; | |
| } else { | |
| outputDiv.innerText = JSON.stringify(data); | |
| } | |
| } catch (error) { | |
| outputDiv.innerText = "حدث خطأ في الشبكة أو المتصفح: " + error.message + | |
| "\n\nملاحظة: إذا كنت تستخدم إضافة لمنع الإعلانات (AdBlocker) أو شبكة محظورة، قم بإيقافها وجرب مجدداً."; | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |