diff options
author | Radamés Ajna <radamajna@gmail.com> | 2023-09-14 22:30:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-15 06:30:50 +0100 |
commit | 5cefbba75777547f97abd92affcf9ef10ac36163 (patch) | |
tree | 835c1f6a79176163958c76287841d3fab467f880 /candle-wasm-examples/llama2-c | |
parent | 130fe5a087715fc4d7bf9b581ca7c11378736ac5 (diff) | |
download | candle-5cefbba75777547f97abd92affcf9ef10ac36163.tar.gz candle-5cefbba75777547f97abd92affcf9ef10ac36163.tar.bz2 candle-5cefbba75777547f97abd92affcf9ef10ac36163.zip |
minor UI fixes (#856)
* fixes
* remove listener
* remove event listener
Diffstat (limited to 'candle-wasm-examples/llama2-c')
-rw-r--r-- | candle-wasm-examples/llama2-c/lib-example.html | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/candle-wasm-examples/llama2-c/lib-example.html b/candle-wasm-examples/llama2-c/lib-example.html index 22b12517..86fe9811 100644 --- a/candle-wasm-examples/llama2-c/lib-example.html +++ b/candle-wasm-examples/llama2-c/lib-example.html @@ -6,7 +6,7 @@ <body></body> </html> -<!doctype html> +<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> @@ -113,8 +113,14 @@ const handleMessage = (event) => { const { status, error, message, prompt, sentence } = event.data; if (status) updateStatus(event.data); - if (error) reject(new Error(error)); - if (status === "complete") resolve(event.data); + if (error) { + llamaWorker.removeEventListener("message", handleMessage); + reject(new Error(error)); + } + if (status === "complete") { + llamaWorker.removeEventListener("message", handleMessage); + resolve(event.data); + } }; controller.signal.addEventListener("abort", handleAbort); |