Add automatic cache point

This commit is contained in:
kwaroran
2025-03-10 13:57:02 +09:00
parent 188e2dd05d
commit 5c2d821445
4 changed files with 35 additions and 0 deletions

View File

@@ -498,6 +498,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
})
}
let hasCachePoint = false
if(promptTemplate){
const template = promptTemplate
@@ -637,6 +638,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
break
}
case 'cache':{
hasCachePoint = true
break
}
}
@@ -1135,6 +1137,21 @@ export async function sendChat(chatProcessIndex = -1,arg:{
chats = systemizeChat(chats)
}
pushPrompts(chats)
if(DBState.db.automaticCachePoint && !hasCachePoint){
let pointer = formated.length - 1
let depthRemaining = 3
while(pointer >= 0){
if(depthRemaining === 0){
break
}
if(formated[pointer].role === 'user'){
formated[pointer].cachePoint = true
depthRemaining--
}
pointer--
}
}
break
}
case 'memory':{