-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.js
28 lines (23 loc) · 946 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
window.onload = async function () {
var stdoutEl = document.querySelector('.stdout');
var stderrEl = document.querySelector('.stderr');
var progressBarFillEl = document.querySelector('.progress-bar-fill');
var progressBarEl = document.querySelector('.progress-bar');
var worker = new Worker('llama2c-worker.js', {type: 'module'});
worker.addEventListener('message', function(event) {
var eventData = event.data;
if (eventData.eventType === 'STDOUT') {
stdoutEl.textContent += eventData.eventData;
}
if (eventData.eventType === 'STDERR') {
stderrEl.textContent += eventData.eventData;
}
if (eventData.eventType === 'MODELDOWNLOADPROGRESS') {
progressBarFillEl.style.width = 100 * eventData.eventData + '%';
if (100 * eventData.eventData > 99) {
progressBarFillEl.textContent = 'stories15M model loaded';
stdoutEl.classList.remove('hidden');
}
}
});
}