From ec524570b4f0eceb195742dbe77963e4c7da65cc Mon Sep 17 00:00:00 2001 From: Nestor Qin Date: Sun, 19 May 2024 20:13:49 -0400 Subject: [PATCH] fix: Correctly reload model after service worker is stopped --- app/client/webllm.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/client/webllm.ts b/app/client/webllm.ts index 2ad4f80b..f05cf780 100644 --- a/app/client/webllm.ts +++ b/app/client/webllm.ts @@ -10,7 +10,7 @@ import { import { ChatOptions, LLMApi, LLMConfig, RequestMessage } from "./api"; -const KEEP_ALIVE_INTERVAL = 10_000; +const KEEP_ALIVE_INTERVAL = 5_000; export class WebLLMApi implements LLMApi { private llmConfig?: LLMConfig; @@ -71,7 +71,9 @@ export class WebLLMApi implements LLMApi { options.onUpdate, ); } catch (err: any) { - if (err.toString().includes("Please call `Engine.reload(model)` first")) { + if ( + !err.toString().includes("Please call `Engine.reload(model)` first") + ) { console.error("Error in chatCompletion", err); options.onError?.(err as Error); return;