From d7789be5e1a19ed51bcef63d82b8eb60f5cd0ec0 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Fri, 19 May 2023 18:45:18 +0900 Subject: [PATCH 1/4] [fix] additional assets not showing --- src/ts/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/parser.ts b/src/ts/parser.ts index 06617d09..940fa111 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -28,7 +28,7 @@ export async function ParseMarkdown(data:string, char:(character | groupChat) = if(char.additionalAssets){ for(const asset of char.additionalAssets){ const assetPath = await getFileSrc(asset[1]) - data = data.replaceAll(`{{raw::${asset[0]}}}`, assetPath).replaceAll(`{{img::${asset[0]}}}`,``) + data = data.replaceAll(`{{raw::${asset[0]}}}`, assetPath).replaceAll(`{{img::${asset[0]}}}`,``) } } } From d30fd7b2146f24493952682926ca5120595ec6b3 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Fri, 19 May 2023 19:25:19 +0900 Subject: [PATCH 2/4] [feat] added supamemory stable --- src/lib/Setting/Pages/AdvancedSettings.svelte | 3 - src/lib/Setting/Pages/OtherBotSettings.svelte | 18 ++++ src/lib/SideBars/CharConfig.svelte | 14 +-- src/ts/database.ts | 10 ++- src/ts/process/index.ts | 2 +- src/ts/process/supaMemory.ts | 85 +++++++++++-------- 6 files changed, 85 insertions(+), 47 deletions(-) diff --git a/src/lib/Setting/Pages/AdvancedSettings.svelte b/src/lib/Setting/Pages/AdvancedSettings.svelte index 28a725a9..f1a54d83 100644 --- a/src/lib/Setting/Pages/AdvancedSettings.svelte +++ b/src/lib/Setting/Pages/AdvancedSettings.svelte @@ -23,9 +23,6 @@ {language.emotionPrompt} -{language.SuperMemory} Prompt - - {language.requestretrys} diff --git a/src/lib/Setting/Pages/OtherBotSettings.svelte b/src/lib/Setting/Pages/OtherBotSettings.svelte index a14c2941..a4a5929a 100644 --- a/src/lib/Setting/Pages/OtherBotSettings.svelte +++ b/src/lib/Setting/Pages/OtherBotSettings.svelte @@ -57,3 +57,21 @@ TTS ElevenLabs API key + + +SupaMemory +{language.SuperMemory} {language.model} + +{#if $DataBase.supaMemoryType === 'davinci' || $DataBase.supaMemoryType === 'curie'} + {language.SuperMemory} OpenAI Key + +{/if} +{#if $DataBase.supaMemoryType !== 'none'} + {language.SuperMemory} Prompt + +{/if} \ No newline at end of file diff --git a/src/lib/SideBars/CharConfig.svelte b/src/lib/SideBars/CharConfig.svelte index 88c42275..d79ea276 100644 --- a/src/lib/SideBars/CharConfig.svelte +++ b/src/lib/SideBars/CharConfig.svelte @@ -224,11 +224,11 @@ {language.jailbreakToggle} - {#if $DataBase.useExperimental} -
- - {language.ToggleSuperMemory} -
+ {#if $DataBase.supaMemoryType !== 'none'} +
+ + {language.ToggleSuperMemory} +
{/if} {:else if subMenu === 1}

{language.characterDisplay}

@@ -518,7 +518,7 @@ {tokens.localNote} {language.tokens} {#if currentChar.data.chats[currentChar.data.chatPage].supaMemoryData && currentChar.data.chats[currentChar.data.chatPage].supaMemoryData.length > 4} - {language.SuperMemory} + {language.SuperMemory} {/if} {#if $DataBase.showUnrecommended || currentChar.data.personality.length > 3} @@ -644,7 +644,7 @@ {:else} {#if currentChar.data.chats[currentChar.data.chatPage].supaMemoryData && currentChar.data.chats[currentChar.data.chatPage].supaMemoryData.length > 4} - {language.SuperMemory} + {language.SuperMemory} {/if} {#if $DataBase.useExperimental} diff --git a/src/ts/database.ts b/src/ts/database.ts index 93346f19..ede4ed14 100644 --- a/src/ts/database.ts +++ b/src/ts/database.ts @@ -193,6 +193,12 @@ export function setDatabase(data:Database){ if(checkNullish(data.showMemoryLimit)){ data.showMemoryLimit = false } + if(checkNullish(data.supaMemoryKey)){ + data.supaMemoryKey = "" + } + if(checkNullish(data.supaMemoryType)){ + data.supaMemoryType = "none" + } if(checkNullish(data.sdConfig)){ data.sdConfig = { width:512, @@ -409,7 +415,9 @@ export interface Database{ showMemoryLimit:boolean roundIcons:boolean useStreaming:boolean - palmAPI:string + palmAPI:string, + supaMemoryKey:string + supaMemoryType:string } diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index 2355805b..9c2c86d2 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -229,7 +229,7 @@ export async function sendChat(chatProcessIndex = -1):Promise { currentTokens += (await tokenize(systemMsg) + 1) } - if(nowChatroom.supaMemory){ + if(nowChatroom.supaMemory && db.supaMemoryType !== 'none'){ const sp = await supaMemory(chats, currentTokens, maxContextTokens, currentChat, nowChatroom) if(sp.error){ alertError(sp.error) diff --git a/src/ts/process/supaMemory.ts b/src/ts/process/supaMemory.ts index b2fa6d77..9d45caba 100644 --- a/src/ts/process/supaMemory.ts +++ b/src/ts/process/supaMemory.ts @@ -95,45 +95,60 @@ export async function supaMemory(chats:OpenAIChat[],currentTokens:number,maxCont "[Summarize the ongoing role story. It must also remove redundancy and unnecessary content from the prompt so that gpt3 and other sublanguage models]\n" : db.supaMemoryPrompt - const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:" + let result = '' - const da = await fetch("https://api.openai.com/v1/completions",{ - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + db.openAIKey - }, - method: "POST", - body: JSON.stringify({ - "model": "text-davinci-003", - "prompt": promptbody, - "max_tokens": 500, - "temperature": 0 + if(db.supaMemoryType !== 'subModel'){ + const promptbody = stringlizedChat + '\n\n' + supaPrompt + "\n\nOutput:" + + const da = await fetch("https://api.openai.com/v1/completions",{ + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + db.openAIKey + }, + method: "POST", + body: JSON.stringify({ + "model": db.supaMemoryType === 'curie' ? "text-curie-001" : "text-davinci-003", + "prompt": promptbody, + "max_tokens": 500, + "temperature": 0 + }) }) - }) - - // const promptbody:OpenAIChat[] = [ - // { - // role: "user", - // content: stringlizedChat - // }, - // { - // role: "system", - // content: supaPrompt - // } - // ] - // const da = await requestChatData({ - // formated: promptbody, - // bias: {} - // }, 'submodel') - - const result = (await da.json()).choices[0].text.trim() - if(da.status < 200 || da.status >= 300){ - return { - currentTokens: currentTokens, - chats: chats, - error: "SupaMemory: HTTP: " + await da.text() + + if(da.status < 200 || da.status >= 300){ + return { + currentTokens: currentTokens, + chats: chats, + error: "SupaMemory: HTTP: " + await da.text() + } } + result = (await da.json()).choices[0].text.trim() } + else { + const promptbody:OpenAIChat[] = [ + { + role: "user", + content: stringlizedChat + }, + { + role: "system", + content: supaPrompt + } + ] + const da = await requestChatData({ + formated: promptbody, + bias: {} + }, 'submodel') + if(da.type === 'fail' || da.type === 'streaming'){ + return { + currentTokens: currentTokens, + chats: chats, + error: "SupaMemory: HTTP: " + da.result + } + } + result = da.result + } + + const tokenz = await tokenize(result + '\n\n') + 5 currentTokens += tokenz From c7d6e3b61dbfb8ec00695d1fcc5a939454774dcb Mon Sep 17 00:00:00 2001 From: kwaroran Date: Fri, 19 May 2023 19:25:54 +0900 Subject: [PATCH 3/4] [fix] streaming retrys --- src/ts/process/request.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/process/request.ts b/src/ts/process/request.ts index 7fe46d66..34235e34 100644 --- a/src/ts/process/request.ts +++ b/src/ts/process/request.ts @@ -30,7 +30,7 @@ export async function requestChatData(arg:requestDataArgument, model:'model'|'su let trys = 0 while(true){ const da = await requestChatDataMain(arg, model) - if(da.type === 'success'){ + if(da.type === 'success' || da.type === 'streaming'){ return da } trys += 1 From c4de57556e3dc733c6522f28ec515bdb32be1fb0 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Fri, 19 May 2023 19:28:13 +0900 Subject: [PATCH 4/4] bump version to 1.13.0 --- src-tauri/tauri.conf.json | 2 +- src/ts/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 d9556299..297b7e54 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "RisuAI", - "version": "1.12.0" + "version": "1.13.0" }, "tauri": { "allowlist": { diff --git a/src/ts/database.ts b/src/ts/database.ts index ede4ed14..bf8141f7 100644 --- a/src/ts/database.ts +++ b/src/ts/database.ts @@ -7,7 +7,7 @@ import { cloneDeep } from 'lodash'; export const DataBase = writable({} as any as Database) export const loadedStore = writable(false) -export let appVer = '1.12.0' +export let appVer = '1.13.0' export function setDatabase(data:Database){ diff --git a/version.json b/version.json index 8dab4229..a26c4f48 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{"version":"1.12.0"} \ No newline at end of file +{"version":"1.13.0"} \ No newline at end of file