Fix hypamemory duplication problem
This commit is contained in:
@@ -526,7 +526,6 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
|
|
||||||
let chats:OpenAIChat[] = examples
|
let chats:OpenAIChat[] = examples
|
||||||
|
|
||||||
console.log(db.aiModel)
|
|
||||||
if(!db.aiModel.startsWith('novelai')){
|
if(!db.aiModel.startsWith('novelai')){
|
||||||
chats.push({
|
chats.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
@@ -1041,7 +1040,6 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(lastResponseChunk)
|
|
||||||
addRerolls(generationId, Object.values(lastResponseChunk))
|
addRerolls(generationId, Object.values(lastResponseChunk))
|
||||||
|
|
||||||
db.characters[selectedChar].chats[selectedChat] = runCurrentChatFunction(db.characters[selectedChar].chats[selectedChat])
|
db.characters[selectedChar].chats[selectedChat] = runCurrentChatFunction(db.characters[selectedChar].chats[selectedChat])
|
||||||
@@ -1211,8 +1209,6 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
return v[0]
|
return v[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(searched)
|
|
||||||
|
|
||||||
for(const emo of currentEmotion){
|
for(const emo of currentEmotion){
|
||||||
if(emo[0] === emoresult[0]){
|
if(emo[0] === emoresult[0]){
|
||||||
const emos:[string, string,number] = [emo[0], emo[1], Date.now()]
|
const emos:[string, string,number] = [emo[0], emo[1], Date.now()]
|
||||||
|
|||||||
@@ -151,30 +151,30 @@ export async function supaMemory(
|
|||||||
value = value.replace(/[\.,\/#!$%\^&\*;:{}=\-_`~()]/g,"")
|
value = value.replace(/[\.,\/#!$%\^&\*;:{}=\-_`~()]/g,"")
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
|
}).filter((v) => {
|
||||||
|
return !supaMemory.replace(/[\.,\/#!$%\^&\*;:{}=\-_`~()]/g,"").includes(v.replace(/[\.,\/#!$%\^&\*;:{}=\-_`~()]/g,""))
|
||||||
}))
|
}))
|
||||||
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), char?.name ?? '', false))
|
const s = await hypa.similaritySearch(stringlizeChat(filteredChat.slice(0, 4), char?.name ?? '', false))
|
||||||
hypaResult = "past events: " + s.slice(0,3).join("\n")
|
hypaResult = ''
|
||||||
currentTokens += await tokenizer.tokenizeChat({
|
if(s.length > 0){
|
||||||
role: "assistant",
|
hypaResult = "past events: " + s.slice(0,3)
|
||||||
content: hypaResult,
|
currentTokens += await tokenizer.tokenizeChat({
|
||||||
memo: "hypaMemory"
|
role: "assistant",
|
||||||
})
|
content: hypaResult,
|
||||||
currentTokens += 10
|
memo: "hypaMemory"
|
||||||
|
})
|
||||||
|
currentTokens += 10
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentTokens < maxContextTokens){
|
if(currentTokens < maxContextTokens){
|
||||||
chats.unshift({
|
chats.unshift({
|
||||||
role: "system",
|
role: "system",
|
||||||
content: supaMemory,
|
content: supaMemory + '\n\n' + hypaResult,
|
||||||
memo: "supaMemory"
|
memo: "supaMemory"
|
||||||
})
|
})
|
||||||
chats.unshift({
|
|
||||||
role: "system",
|
|
||||||
content: hypaResult,
|
|
||||||
memo: "hypaMemory"
|
|
||||||
})
|
|
||||||
return {
|
return {
|
||||||
currentTokens: currentTokens,
|
currentTokens: currentTokens,
|
||||||
chats: chats
|
chats: chats
|
||||||
@@ -313,10 +313,8 @@ export async function supaMemory(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(currentTokens)
|
|
||||||
currentTokens -= await tokenize(supaMemory)
|
currentTokens -= await tokenize(supaMemory)
|
||||||
currentTokens += await tokenize(result + '\n\n')
|
currentTokens += await tokenize(result + '\n\n')
|
||||||
console.log(currentTokens)
|
|
||||||
|
|
||||||
supaMemory = result + '\n\n'
|
supaMemory = result + '\n\n'
|
||||||
summarized = true
|
summarized = true
|
||||||
|
|||||||
Reference in New Issue
Block a user