[fix] supaMemory

This commit is contained in:
kwaroran
2023-06-01 08:03:14 +09:00
parent 262a503e5c
commit 6306e5a1de

View File

@@ -204,28 +204,7 @@ export async function supaMemory(
const tokenz = await tokenize(result + '\n\n') + chatAdditonalTokens
currentTokens += tokenz
supaMemory += result.replace(/\n+/g,'\n') + '\n\n'
let SupaMemoryList = supaMemory.split('\n\n')
if(SupaMemoryList.length >= 5){
const oldSupaMemory = supaMemory
let modifies = []
for(let i=0;i<3;i++){
modifies.push(SupaMemoryList.shift())
}
const result = await summarize(supaMemory)
if(typeof(result) !== 'string'){
return result
}
modifies.unshift(result.replace(/\n+/g,'\n'))
supaMemory = modifies.join('\n\n') + '\n\n'
currentTokens -= await tokenize(oldSupaMemory)
currentTokens += await tokenize(supaMemory)
}
}
}
chats.unshift({