diff options
author | Nicolas Patry <patry.nicolas@protonmail.com> | 2023-07-26 15:17:32 +0200 |
---|---|---|
committer | Nicolas Patry <patry.nicolas@protonmail.com> | 2023-07-26 15:17:32 +0200 |
commit | 035372248e73ea5138bcae58f49904f499ba9d28 (patch) | |
tree | 20161b6229a5efc9d470b5fd747450663acc03db /candle-wasm-examples/llama2-c | |
parent | 97990f4afcd4f918ade85db876f6de9e6d47803e (diff) | |
download | candle-035372248e73ea5138bcae58f49904f499ba9d28.tar.gz candle-035372248e73ea5138bcae58f49904f499ba9d28.tar.bz2 candle-035372248e73ea5138bcae58f49904f499ba9d28.zip |
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.)
Diffstat (limited to 'candle-wasm-examples/llama2-c')
-rw-r--r-- | candle-wasm-examples/llama2-c/src/app.rs | 13 |
1 files changed, 12 insertions, 1 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<std::cell::RefCell<f64>>, 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 { </p> </div> {"temperature: "}<input type="range" min="0." max="1.2" step="0.1" value={self.temperature.borrow().to_string()} {oninput} id="temp"/> - <button class="button" onclick={ctx.link().callback(move |_| Msg::Run)}> { "run" }</button> + + <br/ > + { + if self.loaded{ + html!(<button class="button" onclick={ctx.link().callback(move |_| Msg::Run)}> { "run" }</button>) + }else{ + html! { <progress id="progress-bar" aria-label="Loading weights..."></progress> } + } + } <br/ > <h3> {&self.status} |