feat: Add HypaMemory V2 and SupaMemory descriptions and add hypav2 settings
This commit is contained in:
@@ -612,5 +612,10 @@ export const languageEnglish = {
|
||||
nickname: "Nickname",
|
||||
useRegexLorebook: "Use Regex",
|
||||
customPromptTemplateToggle: "Custom Toggles",
|
||||
defaultVariables: "Default Variables"
|
||||
defaultVariables: "Default Variables",
|
||||
hypaAllocatedTokens: "Allocated Tokens",
|
||||
hypaChunkSize: "Chunk Size",
|
||||
hypaV2Desc: "HypaMemory V2 is a long-term memory system that use both summarized data and vector search.",
|
||||
supaDesc: "SupaMemory is a long-term memory system that uses summarized data to AI.",
|
||||
hanuraiDesc: "HanuraiMemory is a memory system that uses vector search.",
|
||||
}
|
||||
@@ -238,14 +238,20 @@
|
||||
</SelectInput>
|
||||
|
||||
{#if $DataBase.hanuraiEnable}
|
||||
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.hanuraiDesc}</span>
|
||||
<span>Chunk Size</span>
|
||||
<NumberInput size="sm" marginBottom bind:value={$DataBase.hanuraiTokens} min={100} />
|
||||
<div class="flex">
|
||||
<Check bind:check={$DataBase.hanuraiSplit} name="Text Spliting"/>
|
||||
</div>
|
||||
{:else if $DataBase.supaMemoryType === 'hypaV2'}
|
||||
<span class="text-textcolor mt-4">{language.HypaMemory} V2 is Experimental</span>
|
||||
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.hypaV2Desc}</span>
|
||||
<span class="text-textcolor">{language.hypaChunkSize}</span>
|
||||
<NumberInput size="sm" marginBottom bind:value={$DataBase.hypaChunkSize} min={100} />
|
||||
<span class="text-textcolor">{language.hypaAllocatedTokens}</span>
|
||||
<NumberInput size="sm" marginBottom bind:value={$DataBase.hypaAllocatedTokens} min={100} />
|
||||
{:else if $DataBase.supaMemoryType !== 'none'}
|
||||
<span class="mb-2 text-textcolor2 text-sm text-wrap break-words max-w-full">{language.supaDesc}</span>
|
||||
<span class="text-textcolor mt-4">{language.SuperMemory} {language.model}</span>
|
||||
<SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaMemoryType}>
|
||||
<OptionInput value="distilbart" >distilbart-cnn-6-6 (Free/Local)</OptionInput>
|
||||
|
||||
@@ -67,7 +67,8 @@ export async function hypaMemoryV2(
|
||||
|
||||
//this is for the prompt
|
||||
|
||||
let allocatedTokens = 3000
|
||||
let allocatedTokens = db.hypaAllocatedTokens
|
||||
let chunkSize = db.hypaChunkSize
|
||||
currentTokens += allocatedTokens
|
||||
currentTokens += 50 //this is for the template prompt
|
||||
let mainPrompt = ""
|
||||
@@ -93,13 +94,20 @@ export async function hypaMemoryV2(
|
||||
|
||||
while(currentTokens >= maxContextTokens){
|
||||
|
||||
const idx = (Math.floor(chats.length/2))
|
||||
const targetId = chats[idx].memo
|
||||
const halfData = chats.slice(idx)
|
||||
let idx = 0
|
||||
let targetId = ''
|
||||
const halfData:OpenAIChat[] = []
|
||||
|
||||
let halfDataTokens = 0
|
||||
for(const chat of halfData){
|
||||
while(halfDataTokens < chunkSize){
|
||||
const chat = chats[idx]
|
||||
if(!chat){
|
||||
break
|
||||
}
|
||||
halfDataTokens += await tokenizer.tokenizeChat(chat)
|
||||
halfData.push(chat)
|
||||
idx++
|
||||
targetId = chat.memo
|
||||
}
|
||||
|
||||
const stringlizedChat = halfData.map(e => `${e.role}: ${e.content}`).join('\n')
|
||||
|
||||
@@ -403,6 +403,8 @@ export function setDatabase(data:Database){
|
||||
data.customPromptTemplateToggle ??= ''
|
||||
data.globalChatVariables ??= {}
|
||||
data.templateDefaultVariables ??= ''
|
||||
data.hypaAllocatedTokens ??= 3000
|
||||
data.hypaChunkSize ??= 3000
|
||||
|
||||
changeLanguage(data.language)
|
||||
DataBase.set(data)
|
||||
@@ -663,6 +665,8 @@ export interface Database{
|
||||
customPromptTemplateToggle:string
|
||||
globalChatVariables:{[key:string]:string}
|
||||
templateDefaultVariables:string
|
||||
hypaAllocatedTokens:number
|
||||
hypaChunkSize:number
|
||||
}
|
||||
|
||||
export interface customscript{
|
||||
|
||||
Reference in New Issue
Block a user