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",
|
nickname: "Nickname",
|
||||||
useRegexLorebook: "Use Regex",
|
useRegexLorebook: "Use Regex",
|
||||||
customPromptTemplateToggle: "Custom Toggles",
|
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>
|
</SelectInput>
|
||||||
|
|
||||||
{#if $DataBase.hanuraiEnable}
|
{#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>
|
<span>Chunk Size</span>
|
||||||
<NumberInput size="sm" marginBottom bind:value={$DataBase.hanuraiTokens} min={100} />
|
<NumberInput size="sm" marginBottom bind:value={$DataBase.hanuraiTokens} min={100} />
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<Check bind:check={$DataBase.hanuraiSplit} name="Text Spliting"/>
|
<Check bind:check={$DataBase.hanuraiSplit} name="Text Spliting"/>
|
||||||
</div>
|
</div>
|
||||||
{:else if $DataBase.supaMemoryType === 'hypaV2'}
|
{: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'}
|
{: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>
|
<span class="text-textcolor mt-4">{language.SuperMemory} {language.model}</span>
|
||||||
<SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaMemoryType}>
|
<SelectInput className="mt-2 mb-2" bind:value={$DataBase.supaMemoryType}>
|
||||||
<OptionInput value="distilbart" >distilbart-cnn-6-6 (Free/Local)</OptionInput>
|
<OptionInput value="distilbart" >distilbart-cnn-6-6 (Free/Local)</OptionInput>
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ export async function hypaMemoryV2(
|
|||||||
|
|
||||||
//this is for the prompt
|
//this is for the prompt
|
||||||
|
|
||||||
let allocatedTokens = 3000
|
let allocatedTokens = db.hypaAllocatedTokens
|
||||||
|
let chunkSize = db.hypaChunkSize
|
||||||
currentTokens += allocatedTokens
|
currentTokens += allocatedTokens
|
||||||
currentTokens += 50 //this is for the template prompt
|
currentTokens += 50 //this is for the template prompt
|
||||||
let mainPrompt = ""
|
let mainPrompt = ""
|
||||||
@@ -93,13 +94,20 @@ export async function hypaMemoryV2(
|
|||||||
|
|
||||||
while(currentTokens >= maxContextTokens){
|
while(currentTokens >= maxContextTokens){
|
||||||
|
|
||||||
const idx = (Math.floor(chats.length/2))
|
let idx = 0
|
||||||
const targetId = chats[idx].memo
|
let targetId = ''
|
||||||
const halfData = chats.slice(idx)
|
const halfData:OpenAIChat[] = []
|
||||||
|
|
||||||
let halfDataTokens = 0
|
let halfDataTokens = 0
|
||||||
for(const chat of halfData){
|
while(halfDataTokens < chunkSize){
|
||||||
|
const chat = chats[idx]
|
||||||
|
if(!chat){
|
||||||
|
break
|
||||||
|
}
|
||||||
halfDataTokens += await tokenizer.tokenizeChat(chat)
|
halfDataTokens += await tokenizer.tokenizeChat(chat)
|
||||||
|
halfData.push(chat)
|
||||||
|
idx++
|
||||||
|
targetId = chat.memo
|
||||||
}
|
}
|
||||||
|
|
||||||
const stringlizedChat = halfData.map(e => `${e.role}: ${e.content}`).join('\n')
|
const stringlizedChat = halfData.map(e => `${e.role}: ${e.content}`).join('\n')
|
||||||
|
|||||||
@@ -403,6 +403,8 @@ export function setDatabase(data:Database){
|
|||||||
data.customPromptTemplateToggle ??= ''
|
data.customPromptTemplateToggle ??= ''
|
||||||
data.globalChatVariables ??= {}
|
data.globalChatVariables ??= {}
|
||||||
data.templateDefaultVariables ??= ''
|
data.templateDefaultVariables ??= ''
|
||||||
|
data.hypaAllocatedTokens ??= 3000
|
||||||
|
data.hypaChunkSize ??= 3000
|
||||||
|
|
||||||
changeLanguage(data.language)
|
changeLanguage(data.language)
|
||||||
DataBase.set(data)
|
DataBase.set(data)
|
||||||
@@ -663,6 +665,8 @@ export interface Database{
|
|||||||
customPromptTemplateToggle:string
|
customPromptTemplateToggle:string
|
||||||
globalChatVariables:{[key:string]:string}
|
globalChatVariables:{[key:string]:string}
|
||||||
templateDefaultVariables:string
|
templateDefaultVariables:string
|
||||||
|
hypaAllocatedTokens:number
|
||||||
|
hypaChunkSize:number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface customscript{
|
export interface customscript{
|
||||||
|
|||||||
Reference in New Issue
Block a user