From 035372248e73ea5138bcae58f49904f499ba9d28 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 26 Jul 2023 15:17:32 +0200 Subject: Simple QOL. - Add ms/token on llama2.c (15ms/token on my personal machine) - Hide `Run` buttons while models are not ready - Add dummy `progress` while weights are downloading (I briefly looked at putting a real progressbar.. and nothing easy enough came up.) --- candle-wasm-examples/llama2-c/src/app.rs | 13 ++++++++++++- candle-wasm-examples/whisper/src/app.rs | 12 ++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/candle-wasm-examples/llama2-c/src/app.rs b/candle-wasm-examples/llama2-c/src/app.rs index a2a6c53b..a2307471 100644 --- a/candle-wasm-examples/llama2-c/src/app.rs +++ b/candle-wasm-examples/llama2-c/src/app.rs @@ -43,6 +43,7 @@ pub struct CurrentDecode { pub struct App { status: String, + loaded: bool, temperature: std::rc::Rc>, generated: String, n_tokens: usize, @@ -81,6 +82,7 @@ impl Component for App { generated: String::new(), current_decode: None, worker, + loaded: false, } } @@ -102,6 +104,7 @@ impl Component for App { match msg { Msg::SetModel(md) => { self.status = "weights loaded succesfully!".to_string(); + self.loaded = true; console_log!("loaded weights"); self.worker.send(WorkerInput::ModelData(md)); true @@ -186,7 +189,15 @@ impl Component for App {

{"temperature: "} - + +
+ { + if self.loaded{ + html!() + }else{ + html! { } + } + }

{&self.status} diff --git a/candle-wasm-examples/whisper/src/app.rs b/candle-wasm-examples/whisper/src/app.rs index 23519ebd..03ae1d9f 100644 --- a/candle-wasm-examples/whisper/src/app.rs +++ b/candle-wasm-examples/whisper/src/app.rs @@ -47,6 +47,7 @@ pub struct CurrentDecode { pub struct App { status: String, + loaded: bool, segments: Vec, current_decode: Option, worker: Box>, @@ -86,6 +87,7 @@ impl Component for App { segments: vec![], current_decode: None, worker, + loaded: false, } } @@ -107,6 +109,7 @@ impl Component for App { match msg { Msg::SetDecoder(md) => { self.status = "weights loaded succesfully!".to_string(); + self.loaded = true; console_log!("loaded weights"); self.worker.send(WorkerInput::ModelData(md)); true @@ -186,7 +189,10 @@ impl Component for App { {name} - + { if self.loaded { + html!() + }else{html!()} + } } }).collect::() @@ -197,7 +203,9 @@ impl Component for App { {&self.status}

{ - if self.current_decode.is_some() { + if !self.loaded{ + html! { } + } else if self.current_decode.is_some() { html! { } } else { html!{
-- cgit v1.2.3