Update index.html
Browse files- index.html +13 -34
index.html
CHANGED
|
@@ -2,56 +2,35 @@
|
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<title>Тест
|
| 6 |
</head>
|
| 7 |
<body>
|
| 8 |
-
<h2>🧪
|
| 9 |
<div id="status">⏳ Загрузка...</div>
|
| 10 |
-
<button id="send">Спросить</button>
|
| 11 |
<div id="answer"></div>
|
| 12 |
|
| 13 |
<script type="importmap">
|
| 14 |
{
|
| 15 |
"imports": {
|
| 16 |
-
"
|
| 17 |
}
|
| 18 |
}
|
| 19 |
</script>
|
| 20 |
|
| 21 |
<script type="module">
|
| 22 |
-
import * as
|
| 23 |
|
| 24 |
-
const
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
model_id: "Llama-3-8B",
|
| 35 |
-
model_url: modelUrl
|
| 36 |
-
}
|
| 37 |
-
]
|
| 38 |
-
}
|
| 39 |
-
);
|
| 40 |
-
document.getElementById('status').textContent = '✅ Модель загружена!';
|
| 41 |
-
return engine;
|
| 42 |
-
} catch (e) {
|
| 43 |
-
document.getElementById('status').textContent = '❌ Ошибка: ' + e.message;
|
| 44 |
-
}
|
| 45 |
}
|
| 46 |
-
|
| 47 |
-
const engine = await loadModel();
|
| 48 |
-
|
| 49 |
-
document.getElementById('send').onclick = async () => {
|
| 50 |
-
const reply = await engine.chat.completions.create({
|
| 51 |
-
messages: [{ role: "user", content: "Привет, Маруся!" }]
|
| 52 |
-
});
|
| 53 |
-
document.getElementById('answer').textContent = reply.choices[0].message.content;
|
| 54 |
-
};
|
| 55 |
</script>
|
| 56 |
</body>
|
| 57 |
</html>
|
|
|
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<title>Тест ggml.js</title>
|
| 6 |
</head>
|
| 7 |
<body>
|
| 8 |
+
<h2>🧪 ggml.js + Llama</h2>
|
| 9 |
<div id="status">⏳ Загрузка...</div>
|
|
|
|
| 10 |
<div id="answer"></div>
|
| 11 |
|
| 12 |
<script type="importmap">
|
| 13 |
{
|
| 14 |
"imports": {
|
| 15 |
+
"ggml": "https://cdn.jsdelivr.net/npm/ggml.js/+esm"
|
| 16 |
}
|
| 17 |
}
|
| 18 |
</script>
|
| 19 |
|
| 20 |
<script type="module">
|
| 21 |
+
import * as ggml from 'ggml';
|
| 22 |
|
| 23 |
+
const url = 'https://huggingface.co/bartowski/Llama-3-ChatQA-1.5-8B-GGUF/resolve/main/ChatQA-1.5-8B-Q4_K_M.gguf';
|
| 24 |
|
| 25 |
+
try {
|
| 26 |
+
const model = await ggml.load(url);
|
| 27 |
+
document.getElementById('status').textContent = '✅ Модель загружена!';
|
| 28 |
+
|
| 29 |
+
const result = await model.generate('Привет, Маруся!');
|
| 30 |
+
document.getElementById('answer').textContent = '🌸 ' + result;
|
| 31 |
+
} catch (e) {
|
| 32 |
+
document.getElementById('status').textContent = '❌ Ошибка: ' + e.message;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
</script>
|
| 35 |
</body>
|
| 36 |
</html>
|