agentic office

This commit is contained in:
2026-04-02 20:27:37 +03:00
parent 2ad20bdc62
commit 185a40dbdf
13 changed files with 395 additions and 29 deletions

View File

@@ -76,7 +76,7 @@ async fn ensure_cached(key: &str, url: &str, ws: &Rc<RefCell<WebSocket>>) -> Res
}
/// use_3b: false = 0.5B (nopea), true = 3B (laadukas)
pub async fn run_coder_inference(prompt: String, ws: Rc<RefCell<WebSocket>>, use_3b: bool) {
pub async fn run_coder_inference(prompt: String, ws: Rc<RefCell<WebSocket>>, use_3b: bool, task_id: Option<String>) {
let perf = web_sys::window().unwrap().performance().unwrap();
let size_label = if use_3b { "3B" } else { "0.5B" };
@@ -271,7 +271,7 @@ pub async fn run_coder_inference(prompt: String, ws: Rc<RefCell<WebSocket>>, use
let tokens_per_sec = if gen_time > 0.0 { (tokens_generated as f64 / gen_time) * 1000.0 } else { 0.0 };
console_log!("[Coder] {} tokenia | {:.0}ms | {:.1} tok/s", tokens_generated, gen_time, tokens_per_sec);
let done = serde_json::json!({
let mut done = serde_json::json!({
"type": "llm_done",
"prompt": prompt,
"model": format!("Qwen2.5-Coder-{}-Instruct", size_label),
@@ -281,5 +281,8 @@ pub async fn run_coder_inference(prompt: String, ws: Rc<RefCell<WebSocket>>, use
"tokens_per_sec": (tokens_per_sec * 10.0).round() / 10.0,
"load_time_ms": (load_time * 100.0).round() / 100.0,
});
if let Some(tid) = task_id {
done.as_object_mut().unwrap().insert("task_id".to_string(), serde_json::json!(tid));
}
let _ = ws.borrow().send_with_str(&done.to_string());
}