From cac3314e7f6c72ed04565cfab83317d90bf13861 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sat, 13 Apr 2024 23:10:11 +0800 Subject: [PATCH] fix: abort error --- src/services/languageModel/llmWorker/llamaCpp.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/services/languageModel/llmWorker/llamaCpp.ts b/src/services/languageModel/llmWorker/llamaCpp.ts index 9049c7ad..a43a71a0 100644 --- a/src/services/languageModel/llmWorker/llamaCpp.ts +++ b/src/services/languageModel/llmWorker/llamaCpp.ts @@ -169,6 +169,16 @@ export function runLLama( export function abortLLama(conversationID: string) { const abortController = runnerAbortControllers.get(conversationID); if (abortController !== undefined) { - abortController.abort(); + try { + abortController.abort(); + runnerAbortControllers.delete(conversationID); + } catch (error) { + const message = `${(error as Error).message} ${(error as Error).stack ?? 'no stack'}`; + if (message.includes('AbortError')) { + console.info('abortLLama', conversationID); + } else { + throw error; + } + } } }