GalaxyTe commited on
Commit
7c97f0e
·
verified ·
1 Parent(s): 5bb3658

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +15 -25
index.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>🌸 Маруся (чистая версия)</title>
7
  <style>
8
  body {
9
  background: #f5f5fa;
@@ -63,7 +63,7 @@
63
  </head>
64
  <body>
65
  <div id="chat"></div>
66
- <div id="status">⏳ Загрузка модели...</div>
67
  <div class="input-area">
68
  <input type="text" id="input" placeholder="Спроси Марусю..." disabled>
69
  <button id="send" disabled>Отправить</button>
@@ -80,9 +80,6 @@
80
  <script type="module">
81
  import * as webllm from "@mlc-ai/webllm";
82
 
83
- // ============================================================
84
- // КОНФИГ МАРУСИ
85
- // ============================================================
86
  const marusya = class {
87
  static prompt = `
88
  Ты — Маруся.
@@ -103,13 +100,9 @@
103
  N. — пункт нумерованного списка
104
  )
105
  `;
106
-
107
  static model_url = 'https://huggingface.co/bartowski/Llama-3-ChatQA-1.5-8B-GGUF/resolve/main/ChatQA-1.5-8B-Q4_K_M.gguf';
108
  };
109
 
110
- // ============================================================
111
- // ПАРСЕР MARKDOWN
112
- // ============================================================
113
  function parseMarkdown(text) {
114
  text = text.replace(/\\\*/g, '*');
115
  text = text.replace(/\*\*\*(.*?)\*\*\*/g, '<b><i>$1</i></b>');
@@ -124,9 +117,6 @@
124
  return text;
125
  }
126
 
127
- // ============================================================
128
- // ЗАГРУЗКА МОДЕЛИ
129
- // ============================================================
130
  let engine = null;
131
  const status = document.getElementById('status');
132
  const input = document.getElementById('input');
@@ -134,25 +124,30 @@
134
 
135
  async function loadModel() {
136
  try {
137
- status.textContent = '⏳ Загрузка модели (4.92 ГБ)...';
138
- engine = await webllm.CreateMLCEngine(marusya.model_url);
 
 
 
 
 
 
 
 
 
 
139
  status.textContent = '✅ Маруся готова!';
140
  input.disabled = false;
141
  sendBtn.disabled = false;
142
  } catch (e) {
143
- status.textContent = '❌ Ошибка загрузки: ' + e.message;
144
  }
145
  }
146
 
147
  await loadModel();
148
 
149
- // ============================================================
150
- // ОТПРАВКА СООБЩЕНИЙ
151
- // ============================================================
152
  async function sendMessage(text) {
153
  const chat = document.getElementById('chat');
154
-
155
- // Сообщение пользователя
156
  const userMsg = document.createElement('div');
157
  userMsg.className = 'message user';
158
  userMsg.textContent = text;
@@ -166,8 +161,6 @@
166
  ]
167
  });
168
  const answer = reply.choices[0].message.content;
169
-
170
- // Ответ Маруси
171
  const assistantMsg = document.createElement('div');
172
  assistantMsg.className = 'message assistant';
173
  assistantMsg.innerHTML = parseMarkdown(answer);
@@ -180,9 +173,6 @@
180
  }
181
  }
182
 
183
- // ============================================================
184
- // ОБРАБОТКА СОБЫТИЙ
185
- // ============================================================
186
  sendBtn.addEventListener('click', async () => {
187
  const text = input.value.trim();
188
  if (!text) return;
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>🌸 Маруся</title>
7
  <style>
8
  body {
9
  background: #f5f5fa;
 
63
  </head>
64
  <body>
65
  <div id="chat"></div>
66
+ <div id="status">⏳ Загрузка...</div>
67
  <div class="input-area">
68
  <input type="text" id="input" placeholder="Спроси Марусю..." disabled>
69
  <button id="send" disabled>Отправить</button>
 
80
  <script type="module">
81
  import * as webllm from "@mlc-ai/webllm";
82
 
 
 
 
83
  const marusya = class {
84
  static prompt = `
85
  Ты — Маруся.
 
100
  N. — пункт нумерованного списка
101
  )
102
  `;
 
103
  static model_url = 'https://huggingface.co/bartowski/Llama-3-ChatQA-1.5-8B-GGUF/resolve/main/ChatQA-1.5-8B-Q4_K_M.gguf';
104
  };
105
 
 
 
 
106
  function parseMarkdown(text) {
107
  text = text.replace(/\\\*/g, '*');
108
  text = text.replace(/\*\*\*(.*?)\*\*\*/g, '<b><i>$1</i></b>');
 
117
  return text;
118
  }
119
 
 
 
 
120
  let engine = null;
121
  const status = document.getElementById('status');
122
  const input = document.getElementById('input');
 
124
 
125
  async function loadModel() {
126
  try {
127
+ status.textContent = '⏳ Загрузка модели...';
128
+ engine = await webllm.CreateMLCEngine(
129
+ "Llama-3-ChatQA-1.5-8B",
130
+ {
131
+ model_list: [
132
+ {
133
+ model_id: "Llama-3-ChatQA-1.5-8B",
134
+ model_url: marusya.model_url
135
+ }
136
+ ]
137
+ }
138
+ );
139
  status.textContent = '✅ Маруся готова!';
140
  input.disabled = false;
141
  sendBtn.disabled = false;
142
  } catch (e) {
143
+ status.textContent = '❌ Ошибка: ' + e.message;
144
  }
145
  }
146
 
147
  await loadModel();
148
 
 
 
 
149
  async function sendMessage(text) {
150
  const chat = document.getElementById('chat');
 
 
151
  const userMsg = document.createElement('div');
152
  userMsg.className = 'message user';
153
  userMsg.textContent = text;
 
161
  ]
162
  });
163
  const answer = reply.choices[0].message.content;
 
 
164
  const assistantMsg = document.createElement('div');
165
  assistantMsg.className = 'message assistant';
166
  assistantMsg.innerHTML = parseMarkdown(answer);
 
173
  }
174
  }
175
 
 
 
 
176
  sendBtn.addEventListener('click', async () => {
177
  const text = input.value.trim();
178
  if (!text) return;