RecapAnon commited on
Commit ·
f210955
1
Parent(s): bdb7b0c
Add deferred model loading with 'Load model' button.
Browse files- index.html +5 -2
- index.js +15 -1
index.html
CHANGED
|
@@ -270,9 +270,12 @@
|
|
| 270 |
<div class="container">
|
| 271 |
<div class="header">
|
| 272 |
<h1>Ask Miku</h1>
|
| 273 |
-
<div class="status">
|
| 274 |
<span class="status-indicator" id="statusIndicator"></span>
|
| 275 |
-
<span id="statusText">
|
|
|
|
|
|
|
|
|
|
| 276 |
</div>
|
| 277 |
<!-- <div style="margin-top: 12px;">
|
| 278 |
<a href="manage_database.html" style="color: #9ca3af; text-decoration: none; font-size: 13px; transition: color 0.2s;" onmouseover="this.style.color='#d1d5db'" onmouseout="this.style.color='#9ca3af'">
|
|
|
|
| 270 |
<div class="container">
|
| 271 |
<div class="header">
|
| 272 |
<h1>Ask Miku</h1>
|
| 273 |
+
<div class="status" id="statusContainer">
|
| 274 |
<span class="status-indicator" id="statusIndicator"></span>
|
| 275 |
+
<span id="statusText">Ready to load</span>
|
| 276 |
+
</div>
|
| 277 |
+
<div id="loadButtonContainer" style="margin-top: 12px; text-align: center;">
|
| 278 |
+
<button class="send-button" id="loadModelButton">Load model</button>
|
| 279 |
</div>
|
| 280 |
<!-- <div style="margin-top: 12px;">
|
| 281 |
<a href="manage_database.html" style="color: #9ca3af; text-decoration: none; font-size: 13px; transition: color 0.2s;" onmouseover="this.style.color='#d1d5db'" onmouseout="this.style.color='#9ca3af'">
|
index.js
CHANGED
|
@@ -12,6 +12,8 @@ const userInput = document.getElementById('userInput');
|
|
| 12 |
const sendButton = document.getElementById('sendButton');
|
| 13 |
const statusIndicator = document.getElementById('statusIndicator');
|
| 14 |
const statusText = document.getElementById('statusText');
|
|
|
|
|
|
|
| 15 |
|
| 16 |
// State
|
| 17 |
class TextGenerationPipeline {
|
|
@@ -191,6 +193,13 @@ async function initializeModel() {
|
|
| 191 |
function updateStatus(state, text) {
|
| 192 |
statusText.textContent = text;
|
| 193 |
statusIndicator.className = `status-indicator ${state}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
}
|
| 195 |
|
| 196 |
function addMessage(role, content) {
|
|
@@ -380,4 +389,9 @@ userInput.addEventListener('keypress', (e) => {
|
|
| 380 |
}
|
| 381 |
});
|
| 382 |
|
| 383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
const sendButton = document.getElementById('sendButton');
|
| 13 |
const statusIndicator = document.getElementById('statusIndicator');
|
| 14 |
const statusText = document.getElementById('statusText');
|
| 15 |
+
const loadModelButton = document.getElementById('loadModelButton');
|
| 16 |
+
const loadButtonContainer = document.getElementById('loadButtonContainer');
|
| 17 |
|
| 18 |
// State
|
| 19 |
class TextGenerationPipeline {
|
|
|
|
| 193 |
function updateStatus(state, text) {
|
| 194 |
statusText.textContent = text;
|
| 195 |
statusIndicator.className = `status-indicator ${state}`;
|
| 196 |
+
|
| 197 |
+
if (state === 'loading' || state === 'ready' || state === 'error') {
|
| 198 |
+
if (loadModelButton) {
|
| 199 |
+
loadModelButton.disabled = true;
|
| 200 |
+
loadModelButton.textContent = 'Loading...';
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
}
|
| 204 |
|
| 205 |
function addMessage(role, content) {
|
|
|
|
| 389 |
}
|
| 390 |
});
|
| 391 |
|
| 392 |
+
loadModelButton.addEventListener('click', () => {
|
| 393 |
+
if (loadButtonContainer) {
|
| 394 |
+
loadButtonContainer.style.display = 'none';
|
| 395 |
+
}
|
| 396 |
+
initializeModel();
|
| 397 |
+
});
|