mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-20 13:38:49 +01:00
#1152 Filter repeating message hashes when inserting vectors
This commit is contained in:
parent
3de5cdd7e8
commit
dfbeb41afa
@ -182,14 +182,17 @@ async function rearrangeChat(chat) {
|
||||
// Get the most relevant messages, excluding the last few
|
||||
const queryHashes = (await queryCollection(chatId, queryText, settings.insert)).filter(onlyUnique);
|
||||
const queriedMessages = [];
|
||||
const insertedHashes = new Set();
|
||||
const retainMessages = chat.slice(-settings.protect);
|
||||
|
||||
for (const message of chat) {
|
||||
if (retainMessages.includes(message)) {
|
||||
if (retainMessages.includes(message) || !message.mes) {
|
||||
continue;
|
||||
}
|
||||
if (message.mes && queryHashes.includes(getStringHash(message.mes))) {
|
||||
const hash = getStringHash(message.mes);
|
||||
if (queryHashes.includes(hash) && !insertedHashes.has(hash)) {
|
||||
queriedMessages.push(message);
|
||||
insertedHashes.add(hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user