Add automatic cache point
This commit is contained in:
@@ -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.",
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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':{
|
||||
|
||||
@@ -925,6 +925,8 @@ export interface Database{
|
||||
},
|
||||
localActivationInGlobalLorebook: boolean
|
||||
showFolderName: boolean
|
||||
automaticCachePoint: boolean
|
||||
chatCompression: boolean
|
||||
}
|
||||
|
||||
interface SeparateParameters{
|
||||
|
||||
Reference in New Issue
Block a user