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