Download index.html from Maleu813/jobo: direct link, hf CLI and curl.
- Browser
- Download file 5.32 kB
-
https://huggingface.co/spaces/Maleu813/jobo/resolve/main/index.html
- Command line
-
hf download hf://spaces/Maleu813/jobo/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Maleu813/jobo/resolve/main/index.html
5.32 kB
| <html lang="ar" dir="rtl"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>جوبو ٢</title> | |
| <style> | |
| :root{--bg:#f6f7f9;--card:#fff;--text:#1d2330;--muted:#6b7385;--line:#e3e6ec;--me:#2563eb;--me-text:#fff;--bot:#eef1f6} | |
| @media (prefers-color-scheme:dark){:root{--bg:#0f1218;--card:#171b23;--text:#e8ebf1;--muted:#9aa3b5;--line:#272d39;--me:#3b82f6;--bot:#202633}} | |
| *{box-sizing:border-box} | |
| body{margin:0;background:var(--bg);color:var(--text);font:16px/1.7 system-ui,"Segoe UI",Tahoma,sans-serif;height:100dvh;display:flex;flex-direction:column} | |
| header{padding:14px 16px;border-bottom:1px solid var(--line);background:var(--card)} | |
| header h1{margin:0;font-size:19px} | |
| header p{margin:2px 0 0;color:var(--muted);font-size:13px} | |
| #log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px;max-width:760px;width:100%;margin:0 auto} | |
| .msg{max-width:85%;padding:9px 13px;border-radius:14px;white-space:pre-wrap;word-wrap:break-word} | |
| .me{align-self:flex-start;background:var(--me);color:var(--me-text);border-bottom-right-radius:4px} | |
| .bot{align-self:flex-end;background:var(--bot);border-bottom-left-radius:4px} | |
| #status{text-align:center;color:var(--muted);font-size:14px;padding:6px} | |
| .chips{display:flex;gap:6px;flex-wrap:wrap;justify-content:center;padding:0 16px 6px} | |
| .chips button{border:1px solid var(--line);background:var(--card);color:var(--text);border-radius:99px;padding:4px 12px;font:inherit;font-size:14px;cursor:pointer} | |
| form{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--line);background:var(--card)} | |
| form>div{display:flex;gap:8px;max-width:760px;width:100%;margin:0 auto} | |
| input{flex:1;min-width:0;border:1px solid var(--line);background:var(--bg);color:var(--text);border-radius:10px;padding:10px 12px;font:inherit} | |
| button.send{border:0;background:var(--me);color:#fff;border-radius:10px;padding:0 18px;font:inherit;cursor:pointer} | |
| button:disabled{opacity:.5;cursor:default} | |
| </style> | |
| </head> | |
| <body> | |
| <header><h1>جوبو ٢ 🤖</h1><p>مساعد عربي صغير (61 مليون وسيط) صنعه مهدي. يعمل داخل متصفحك مباشرة، وقد يخطئ في المعلومات.</p></header> | |
| <div id="log"></div> | |
| <div id="status">جارٍ تحميل جوبو…</div> | |
| <div class="chips" id="chips"></div> | |
| <form id="f"><div><input id="q" placeholder="اكتب رسالتك…" autocomplete="off" disabled><button class="send" id="send" disabled>إرسال</button></div></form> | |
| <script type="module"> | |
| import { Wllama } from "https://cdn.jsdelivr.net/npm/@wllama/wllama@3.6.1/esm/index.js"; | |
| const $ = (id) => document.getElementById(id); | |
| const log = $("log"), status = $("status"), q = $("q"), send = $("send"); | |
| const history = []; | |
| const wllama = new Wllama({ default: "https://cdn.jsdelivr.net/npm/@wllama/wllama@3.6.1/esm/wasm/wllama.wasm" }); | |
| function normalize(t) { // نفس تطبيع التدريب | |
| return (t || "").normalize("NFC") | |
| .replace(/[---]/g, "") | |
| .replace(/[ً-ْـ]/g, "") | |
| .replace(/[٠-٩]/g, (d) => String(d.charCodeAt(0) - 0x660)) | |
| .replace(/[ \t ]+/g, " ").replace(/\n{3,}/g, "\n\n").trim().toLowerCase(); | |
| } | |
| function bubble(cls, text) { | |
| const d = document.createElement("div"); d.className = "msg " + cls; d.textContent = text; | |
| log.appendChild(d); log.scrollTop = log.scrollHeight; return d; | |
| } | |
| function buildPrompt() { | |
| let p = "<s>"; | |
| for (const m of history.slice(-8)) p += `<|${m.role}|>${normalize(m.content)}<|end|>`; | |
| return p + "<|assistant|>"; | |
| } | |
| async function ask(text) { | |
| text = text.trim(); if (!text) return; | |
| q.value = ""; q.disabled = send.disabled = true; | |
| bubble("me", text); history.push({ role: "user", content: text }); | |
| const b = bubble("bot", "…"); let out = ""; | |
| try { | |
| const stream = await wllama.createCompletion({ | |
| prompt: buildPrompt(), stream: true, max_tokens: 200, | |
| temperature: 0.3, top_k: 40, top_p: 0.9, repeat_penalty: 1.2, repeat_last_n: 128, | |
| stop: ["<|end|>", "<|user|>", "</s>"], | |
| }); | |
| for await (const c of stream) { | |
| out += c.choices?.[0]?.text ?? ""; | |
| b.textContent = out.replace(/<\|end\|>.*$/s, "").trim() || "…"; | |
| log.scrollTop = log.scrollHeight; | |
| } | |
| } catch (e) { b.textContent = "حدث خطأ: " + e.message; } | |
| history.push({ role: "assistant", content: b.textContent }); | |
| q.disabled = send.disabled = false; q.focus(); | |
| } | |
| $("f").onsubmit = (e) => { e.preventDefault(); if (!send.disabled) ask(q.value); }; | |
| for (const s of ["من أنت؟", "ما عاصمة مصر؟", "ما فائدة الرياضة؟", "احكِ لي قصة قصيرة"]) { | |
| const c = document.createElement("button"); c.textContent = s; c.onclick = () => !send.disabled && ask(s); | |
| $("chips").appendChild(c); | |
| } | |
| try { | |
| await wllama.loadModelFromHF({ repo: "Maleu813/jobo2", file: "jobo2-q8_0.gguf" }, { | |
| n_ctx: 1024, | |
| progressCallback: ({ loaded, total }) => { status.textContent = `جارٍ تحميل جوبو… ${Math.round(loaded / total * 100)}%`; }, | |
| }); | |
| status.textContent = "جوبو جاهز — اسأله أي شيء"; | |
| q.disabled = send.disabled = false; q.focus(); | |
| window.jobo = { wllama, ask }; | |
| } catch (e) { status.textContent = "تعذّر تحميل النموذج: " + e.message; } | |
| </script> | |
| </body> | |
| </html> | |