feat: add doNotSummarizeUserChat option in HypaV3

- Add doNotSummarizeUserChat option to exclude user messages from summarization
- Add early return logic to prevent unnecessary similarity checks when summaries are empty
This commit is contained in:
Bo26fhmC5M
2025-02-07 21:08:50 +09:00
parent 7b57bdf5f1
commit 6d79f45d32
3 changed files with 47 additions and 5 deletions

View File

@@ -421,6 +421,12 @@ export async function hypaMemoryV3(
continue;
}
if (db.hypaV3Settings.doNotSummarizeUserChat && chat.role === "user") {
console.log(`[HypaV3] Skipping user role at index ${i}`);
continue;
}
toSummarize.push(chat);
}
@@ -469,6 +475,37 @@ export async function hypaMemoryV3(
availableMemoryTokens
);
// Early return if no summaries
if (data.summaries.length === 0) {
// Generate final memory prompt
const memory = encapsulateMemoryPrompt("");
const newChats: OpenAIChat[] = [
{
role: "system",
content: memory,
memo: "supaMemory",
},
...chats.slice(startIdx),
];
console.log(
"[HypaV3] Exiting function:",
"\nCurrent Tokens:",
currentTokens,
"\nAll chats, including memory prompt:",
newChats,
"\nMemory Data:",
data
);
return {
currentTokens,
chats: newChats,
memory: toSerializableHypaV3Data(data),
};
}
const selectedSummaries: Summary[] = [];
const randomMemoryRatio =
1 -