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

@@ -1065,4 +1065,10 @@ export const languageEnglish = {
cachePoint: "Cache Point",
all: "All",
showFolderNameInIcon: "Show Folder Name in Icon",
claudeCachingRetrival: "Claude Caching Retrival",
claudeCachingRetrivalDesc: "Extends the cache time for Claude Caching, by requesting every 4 minutes. this can reduce the cache miss rate, but it can increase the cost if its not used properly.",
automaticCachePoint: "Automatic Cache Point",
automaticCachePointDesc: "Automatically creates cache point after the chat ends, if the caching point doesn't exist.",
experimentalChatCompression: "Experimental Chat Data Handling",
experimentalChatCompressionDesc: "Compresses the unused chat data and saves in seperate file.",
}

View File

@@ -160,6 +160,16 @@
<Help key="experimental"/>
</Check>
</div>
<div class="flex items-center mt-4">
<Check bind:check={DBState.db.automaticCachePoint} name={language.automaticCachePoint}>
<Help key="experimental"/><Help key="experimental"/>
</Check>
</div>
<div class="flex items-center mt-4">
<Check bind:check={DBState.db.chatCompression} name={language.experimentalChatCompression}>
<Help key="experimental"/><Help key="experimental"/>
</Check>
</div>
{/if}
{#if DBState.db.showUnrecommended}
<div class="flex items-center mt-4">

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':{

View File

@@ -925,6 +925,8 @@ export interface Database{
},
localActivationInGlobalLorebook: boolean
showFolderName: boolean
automaticCachePoint: boolean
chatCompression: boolean
}
interface SeparateParameters{