feat: Add HypaMemory V2 and SupaMemory descriptions and add hypav2 settings

This commit is contained in:
kwaroran
2024-05-27 12:30:07 +09:00
parent 584643ac87
commit 4ad59fa69c
4 changed files with 30 additions and 7 deletions

View File

@@ -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')

View File

@@ -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{