Fix vectorize all with no chat selected

This commit is contained in:
Cohee 2023-09-10 19:47:41 +03:00
parent 17367f2b17
commit c9d8d7ba64
1 changed files with 7 additions and 1 deletions

View File

@ -27,6 +27,12 @@ async function onVectorizeAllClick() {
} }
const chatId = getCurrentChatId(); const chatId = getCurrentChatId();
if (!chatId) {
toastr.info('No chat selected', 'Vectorization aborted');
return;
}
const batchSize = 5; const batchSize = 5;
const elapsedLog = []; const elapsedLog = [];
let finished = false; let finished = false;
@ -89,7 +95,7 @@ async function synchronizeChat(batchSize = 5) {
if (!chatId || !Array.isArray(context.chat)) { if (!chatId || !Array.isArray(context.chat)) {
console.debug('Vectors: No chat selected'); 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) })); const hashedMessages = context.chat.filter(x => !x.is_system).map(x => ({ text: String(x.mes), hash: getStringHash(x.mes) }));