Vector Storage: Fix query summarizing for WI and files
| @@ -401,7 +401,7 @@ async function processFiles(chat) { | ||
| 401 | 401 | const dataBankCollectionIds = await ingestDataBankAttachments(); |
| 402 | 402 | |
| 403 | 403 | if (dataBankCollectionIds.length) { |
| 404 | 404 | const queryText = await getQueryText(chat, 'file'); |
| 405 | 405 | await injectDataBankChunks(queryText, dataBankCollectionIds); |
| 406 | 406 | } |
| 407 | 407 | |
| @@ -435,7 +435,7 @@ async function processFiles(chat) { | ||
| 435 | 435 | await vectorizeFile(fileText, fileName, collectionId, settings.chunk_size, settings.overlap_percent); |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | const queryText = await getQueryText(chat, 'file'); |
| 439 | 439 | const fileChunks = await retrieveFileChunks(queryText, collectionId); |
| 440 | 440 | |
| 441 | 441 | message.mes = `${fileChunks}\n\n${message.mes}`; |
| @@ -596,7 +596,7 @@ async function rearrangeChat(chat) { | ||
| 596 | 596 | return; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | const queryText = await getQueryText(chat, 'chat'); |
| 600 | 600 | |
| 601 | 601 | if (queryText.length === 0) { |
| 602 | 602 | console.debug('Vectors: No text to query'); |
| @@ -683,15 +683,16 @@ const onChatEvent = debounce(async () => await moduleWorker.update(), debounce_t | ||
| 683 | 683 | /** |
| 684 | 684 | * Gets the text to query from the chat |
| 685 | 685 | * @param {object[]} chat Chat messages |
| 686 | + * @param {'file'|'chat'|'world-info'} initiator Initiator of the query | |
| 686 | 687 | * @returns {Promise<string>} Text to query |
| 687 | 688 | */ |
| 688 | 689 | async function getQueryText(chat, initiator) { |
| 689 | 690 | let queryText = ''; |
| 690 | 691 | let i = 0; |
| 691 | 692 | |
| 692 | 693 | let hashedMessages = chat.map(x => ({ text: String(substituteParams(x.mes)) })); |
| 693 | 694 | |
| 694 | 695 | if (initiator === 'chat' && settings.enabled_chats && settings.summarize && settings.summarize_sent) { |
| 695 | 696 | hashedMessages = await summarize(hashedMessages, settings.summary_source); |
| 696 | 697 | } |
| 697 | 698 | |
| @@ -1279,7 +1280,7 @@ async function activateWorldInfo(chat) { | ||
| 1279 | 1280 | } |
| 1280 | 1281 | |
| 1281 | 1282 | // Perform a multi-query |
| 1282 | 1283 | const queryText = await getQueryText(chat, 'world-info'); |
| 1283 | 1284 | |
| 1284 | 1285 | if (queryText.length === 0) { |
| 1285 | 1286 | console.debug('Vectors: No text to query for WI'); |