From 71b02cf10411c3ad75e2a4c86864d3b1fdf80dcc Mon Sep 17 00:00:00 2001 From: kwaroran Date: Mon, 29 May 2023 20:41:33 +0900 Subject: [PATCH 1/2] [fix] tokenize problem --- src/ts/process/index.ts | 10 ++++++---- src/ts/process/supaMemory.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index 48f2e733..f795b5a1 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -93,6 +93,7 @@ export async function sendChat(chatProcessIndex = -1):Promise { } } + let unformated = { 'main':([] as OpenAIChat[]), 'jailbreak':([] as OpenAIChat[]), @@ -162,10 +163,11 @@ export async function sendChat(chatProcessIndex = -1):Promise { }).join('\n\n') }).join('\n\n')) + db.maxResponse) + 150 + const examples = exampleMessage(currentChar) for(const example of examples){ - currentTokens += await tokenize(example.content) + currentTokens += await tokenize(example.content) + 5 } let chats:OpenAIChat[] = examples @@ -215,7 +217,7 @@ export async function sendChat(chatProcessIndex = -1):Promise { memo: msg.chatId, name: name }) - currentTokens += (await tokenize(formedChat) + 1) + currentTokens += (await tokenize(formedChat) + 5) } if(nowChatroom.type === 'group'){ @@ -224,7 +226,7 @@ export async function sendChat(chatProcessIndex = -1):Promise { role: 'system', content: systemMsg }) - currentTokens += (await tokenize(systemMsg) + 1) + currentTokens += (await tokenize(systemMsg) + 5) } if(nowChatroom.supaMemory && db.supaMemoryType !== 'none'){ @@ -246,7 +248,7 @@ export async function sendChat(chatProcessIndex = -1):Promise { return false } - currentTokens -= (await tokenize(chats[0].content) + 1) + currentTokens -= (await tokenize(chats[0].content) + 5) chats.splice(0, 1) } currentChat.lastMemory = chats[0].memo diff --git a/src/ts/process/supaMemory.ts b/src/ts/process/supaMemory.ts index 7d5796ea..e58e1876 100644 --- a/src/ts/process/supaMemory.ts +++ b/src/ts/process/supaMemory.ts @@ -171,7 +171,7 @@ export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxCont } continue } - const tokens = await tokenize(cont.content) + 1 + const tokens = await tokenize(cont.content) + 5 if((chunkSize + tokens) > maxChunkSize){ if(stringlizedChat === ''){ stringlizedChat += `${cont.role === 'assistant' ? char.type === 'group' ? '' : char.name : db.username}: ${cont.content}\n\n` From 78050929923289e8528a4b9eff9c11a5c92d5955 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 30 May 2023 20:38:11 +0900 Subject: [PATCH 2/2] bump version to 1.21.1 --- src-tauri/tauri.conf.json | 2 +- src/ts/storage/database.ts | 2 +- version.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 027dc517..a79a99b6 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "RisuAI", - "version": "1.21.1" + "version": "1.21.2" }, "tauri": { "allowlist": { diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts index 72936208..37a49d68 100644 --- a/src/ts/storage/database.ts +++ b/src/ts/storage/database.ts @@ -8,7 +8,7 @@ import { defaultJailbreak, defaultMainPrompt } from './defaultPrompts'; export const DataBase = writable({} as any as Database) export const loadedStore = writable(false) -export let appVer = '1.21.1' +export let appVer = '1.21.2' export function setDatabase(data:Database){ if(checkNullish(data.characters)){ diff --git a/version.json b/version.json index 65957cd7..abf4c30b 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{"version":"1.21.1"} \ No newline at end of file +{"version":"1.21.2"} \ No newline at end of file