mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #673 from 50h100a/sc-tweaks
This commit is contained in:
@@ -615,7 +615,6 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
|||||||
const lastMessage = chat[chat.length - 1];
|
const lastMessage = chat[chat.length - 1];
|
||||||
|
|
||||||
let queriedMessages;
|
let queriedMessages;
|
||||||
console.debug(recallStrategy)
|
|
||||||
if (lastMessage) {
|
if (lastMessage) {
|
||||||
let queryBlob = "";
|
let queryBlob = "";
|
||||||
if (chromaQueryLastOnly) {
|
if (chromaQueryLastOnly) {
|
||||||
@@ -626,7 +625,7 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
|||||||
queryBlob += `${msg.mes}\n`
|
queryBlob += `${msg.mes}\n`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("CHROMADB: Query text:", queryBlob);
|
console.debug("CHROMADB: Query text:", queryBlob);
|
||||||
|
|
||||||
if (recallStrategy === 'multichat') {
|
if (recallStrategy === 'multichat') {
|
||||||
console.log("Utilizing multichat")
|
console.log("Utilizing multichat")
|
||||||
@@ -688,17 +687,17 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
|||||||
memoryMsg += " {{message}}";
|
memoryMsg += " {{message}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reversed because we want the most important messages at the bottom.
|
// Reversed because we want the most 'important' messages at the bottom.
|
||||||
let recalledMemories = queriedMessages.map(m => m.meta).filter(onlyUnique).map(JSON.parse).reverse();
|
let recalledMemories = queriedMessages.map(m => m.meta).filter(onlyUnique).map(JSON.parse).reverse();
|
||||||
let tokenApprox = 0;
|
let tokenApprox = 0;
|
||||||
let allMemoryBlob = "";
|
let allMemoryBlob = "";
|
||||||
for (let msg of recalledMemories) {
|
for (const msg of recalledMemories) {
|
||||||
let memoryBlob = memoryMsg.replace('{{name}}', msg.name).replace('{{message}}', msg.mes);
|
const memoryBlob = memoryMsg.replace('{{name}}', msg.name).replace('{{message}}', msg.mes);
|
||||||
tokenApprox += (memoryBlob.length / CHARACTERS_PER_TOKEN_RATIO);
|
const memoryTokens = (memoryBlob.length / CHARACTERS_PER_TOKEN_RATIO);
|
||||||
if (tokenApprox > chromaTokenLimit) {
|
if (tokenApprox + memoryTokens <= chromaTokenLimit) {
|
||||||
break;
|
allMemoryBlob += memoryBlob;
|
||||||
|
tokenApprox += memoryTokens;
|
||||||
}
|
}
|
||||||
allMemoryBlob += memoryBlob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const promptBlob = wrapperMsg.replace('{{memories}}', allMemoryBlob);
|
const promptBlob = wrapperMsg.replace('{{memories}}', allMemoryBlob);
|
||||||
|
Reference in New Issue
Block a user