[fix] supamemory and hypamemory using too much tokens

This commit is contained in:
kwaroran
2023-06-29 08:06:03 +09:00
parent 1f9924ddda
commit 6d4b592a25

View File

@@ -208,7 +208,7 @@ export async function supaMemory(
await hypa.addText(hypaChunks) await hypa.addText(hypaChunks)
const filteredChat = chats.filter((r) => r.role !== 'system' && r.role !== 'function') const filteredChat = chats.filter((r) => r.role !== 'system' && r.role !== 'function')
const s = await hypa.similaritySearch(stringlizeChat(filteredChat.slice(0, 4))) const s = await hypa.similaritySearch(stringlizeChat(filteredChat.slice(0, 4)))
hypaResult = s.slice(0,4).join("\n\n") hypaResult = s.slice(0,3).join("\n\n")
currentTokens += await tokenizer.tokenizeChat({ currentTokens += await tokenizer.tokenizeChat({
role: "assistant", role: "assistant",
content: hypaResult content: hypaResult
@@ -289,7 +289,7 @@ export async function supaMemory(
supaMemory += result.replace(/\n+/g,'\n') + '\n\n' supaMemory += result.replace(/\n+/g,'\n') + '\n\n'
let SupaMemoryList = supaMemory.split('\n\n') let SupaMemoryList = supaMemory.split('\n\n')
if(SupaMemoryList.length >= 5){ if(SupaMemoryList.length >= (arg.asHyper ? 3 : 4)){
const oldSupaMemory = supaMemory const oldSupaMemory = supaMemory
let modifies:string[] = [] let modifies:string[] = []
for(let i=0;i<3;i++){ for(let i=0;i<3;i++){