Vector Storage: Fix query summarizing for WI and files

c88edaa4ed20c6b22ca89fff91b2001a2fb08c8e

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +7 -6Showing whitespace changes
public/scripts/extensions/vectors/index.js+7 -6
@@ -401,7 +401,7 @@ async function processFiles(chat) {
401401 const dataBankCollectionIds = await ingestDataBankAttachments();
402402
403403 if (dataBankCollectionIds.length) {
404404 const queryText = await getQueryText(chat, 'file');
405405 await injectDataBankChunks(queryText, dataBankCollectionIds);
406406 }
407407
@@ -435,7 +435,7 @@ async function processFiles(chat) {
435435 await vectorizeFile(fileText, fileName, collectionId, settings.chunk_size, settings.overlap_percent);
436436 }
437437
438438 const queryText = await getQueryText(chat, 'file');
439439 const fileChunks = await retrieveFileChunks(queryText, collectionId);
440440
441441 message.mes = `${fileChunks}\n\n${message.mes}`;
@@ -596,7 +596,7 @@ async function rearrangeChat(chat) {
596596 return;
597597 }
598598
599599 const queryText = await getQueryText(chat, 'chat');
600600
601601 if (queryText.length === 0) {
602602 console.debug('Vectors: No text to query');
@@ -683,15 +683,16 @@ const onChatEvent = debounce(async () => await moduleWorker.update(), debounce_t
683683/**
684684 * Gets the text to query from the chat
685685 * @param {object[]} chat Chat messages
686+ * @param {'file'|'chat'|'world-info'} initiator Initiator of the query
686687 * @returns {Promise<string>} Text to query
687688 */
688689async function getQueryText(chat, initiator) {
689690 let queryText = '';
690691 let i = 0;
691692
692693 let hashedMessages = chat.map(x => ({ text: String(substituteParams(x.mes)) }));
693694
694695 if (initiator === 'chat' && settings.enabled_chats && settings.summarize && settings.summarize_sent) {
695696 hashedMessages = await summarize(hashedMessages, settings.summary_source);
696697 }
697698
@@ -1279,7 +1280,7 @@ async function activateWorldInfo(chat) {
12791280 }
12801281
12811282 // Perform a multi-query
12821283 const queryText = await getQueryText(chat, 'world-info');
12831284
12841285 if (queryText.length === 0) {
12851286 console.debug('Vectors: No text to query for WI');