Skip to content

Commit

Permalink
fix: prevent abort throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Apr 13, 2024
1 parent cac3314 commit 47e0535
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/services/languageModel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class LanguageModel implements ILanguageModelService {
};
void runLanguageModelObserverIIFE().catch(error => {
const message = `${(error as Error).message} ${(error as Error).stack ?? 'no stack'}`;
logger.error(message, { id: conversationID, function: 'LanguageModel.runLanguageModel$.error' });
logger.error(message, { id: conversationID, function: 'runLanguageModelObserverIIFE.error' });
void this.nativeService.showElectronMessageBox({
title: i18n.t('LanguageModel.RunModelError'),
message,
Expand Down
14 changes: 12 additions & 2 deletions src/services/languageModel/llmWorker/llamaCpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export function loadLLamaAndModel(
async function loadLLamaAndModelIIFE() {
subscriber.next({ message: `library loaded, new LLM now with LLAMA_PREBUILT_BINS_DIRECTORY ${LLAMA_PREBUILT_BINS_DIRECTORY}`, ...loggerCommonMeta });
try {
// add an initial progress, so user immediately know load is started.
subscriber.next({
type: 'progress',
percentage: 0.0001,
id: conversationID,
});
llamaInstance = await getLlama({
skipDownload: true,
vramPadding: 0,
Expand Down Expand Up @@ -160,8 +166,12 @@ export function runLLama(
subscriber.complete();
subscriber.next({ message: 'createCompletion completed', ...loggerCommonMeta });
} catch (error) {
runnerAbortControllers.delete(conversationID);
subscriber.error(error);
if ((error as Error).message.includes('aborted')) {
console.info('abortLLama', conversationID);
} else {
runnerAbortControllers.delete(conversationID);
subscriber.error(error);
}
}
})();
});
Expand Down

0 comments on commit 47e0535

Please sign in to comment.