From c9d8d7ba6472a411c7b27b63ee0573a0cc736719 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 10 Sep 2023 19:47:41 +0300 Subject: [PATCH] Fix vectorize all with no chat selected --- public/scripts/extensions/vectors/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/scripts/extensions/vectors/index.js b/public/scripts/extensions/vectors/index.js index 6232e4519..b60b3ec60 100644 --- a/public/scripts/extensions/vectors/index.js +++ b/public/scripts/extensions/vectors/index.js @@ -27,6 +27,12 @@ async function onVectorizeAllClick() { } const chatId = getCurrentChatId(); + + if (!chatId) { + toastr.info('No chat selected', 'Vectorization aborted'); + return; + } + const batchSize = 5; const elapsedLog = []; let finished = false; @@ -89,7 +95,7 @@ async function synchronizeChat(batchSize = 5) { if (!chatId || !Array.isArray(context.chat)) { console.debug('Vectors: No chat selected'); - return; + return -1; } const hashedMessages = context.chat.filter(x => !x.is_system).map(x => ({ text: String(x.mes), hash: getStringHash(x.mes) }));