From 10d910141ba007fc0e401f3ff62651a7b8dcdb51 Mon Sep 17 00:00:00 2001 From: bangonicdd <157843588+bangonicdd2@users.noreply.github.com> Date: Sat, 3 Feb 2024 22:35:11 +0900 Subject: [PATCH 1/3] Add persona portraits with lesser change --- src/lang/en.ts | 1 + src/lang/ko.ts | 1 + src/lib/ChatScreens/DefaultChatScreen.svelte | 1 + src/lib/Setting/Pages/PersonaSettings.svelte | 4 +++- src/ts/persona.ts | 8 +++----- src/ts/storage/database.ts | 1 + 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lang/en.ts b/src/lang/en.ts index 5975574f..9e4a6a61 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -515,4 +515,5 @@ export const languageEnglish = { license: "License", licenseDesc: "You can choose license for the downloaders to limit the usages of your card's prompt.", passwordDesc: "You can set a password to protect your card from unauthorized access.", + largePersonaPortrait: "Persona Portrait", } \ No newline at end of file diff --git a/src/lang/ko.ts b/src/lang/ko.ts index cd71656e..89e4f55e 100644 --- a/src/lang/ko.ts +++ b/src/lang/ko.ts @@ -429,4 +429,5 @@ export const languageKorean = { template: "템플릿", editTranslationDisplay: "번역문 수정", memoryLimitThickness: "기억 한계선 두께", + largePersonaPortrait: "페르소나 세로 이미지", } \ No newline at end of file diff --git a/src/lib/ChatScreens/DefaultChatScreen.svelte b/src/lib/ChatScreens/DefaultChatScreen.svelte index 22991339..ee724eb8 100644 --- a/src/lib/ChatScreens/DefaultChatScreen.svelte +++ b/src/lib/ChatScreens/DefaultChatScreen.svelte @@ -527,6 +527,7 @@ message={chat.data} img={getCharImage($CurrentUserIcon, 'css')} isLastMemory={$CurrentChat.lastMemory === (chat.chatId ?? 'none') && $CurrentShowMemoryLimit} + largePortrait={$DataBase.personas[$DataBase.selectedPersona].largePortrait} /> {/if} {/each} diff --git a/src/lib/Setting/Pages/PersonaSettings.svelte b/src/lib/Setting/Pages/PersonaSettings.svelte index 9a557f0a..01366bc9 100644 --- a/src/lib/Setting/Pages/PersonaSettings.svelte +++ b/src/lib/Setting/Pages/PersonaSettings.svelte @@ -2,6 +2,7 @@ import { language } from "src/lang"; import BaseRoundedButton from "src/lib/UI/BaseRoundedButton.svelte"; import Button from "src/lib/UI/GUI/Button.svelte"; + import Check from "src/lib/UI/GUI/CheckInput.svelte"; import TextAreaInput from "src/lib/UI/GUI/TextAreaInput.svelte"; import TextInput from "src/lib/UI/GUI/TextInput.svelte"; import { alertConfirm, alertError, alertSelect } from "src/ts/alert"; @@ -69,7 +70,7 @@ {#if $DataBase.userIcon === ''}
{:else} - {#await getCharImage($DataBase.userIcon, 'css')} + {#await getCharImage($DataBase.userIcon, $DataBase.personas[$DataBase.selectedPersona].largePortrait ? 'lgcss' : 'css')}
{:then im}
@@ -99,6 +100,7 @@ changeUserPersona(0, 'noSave') } }}>{language.remove} + {language.largePortrait}
\ No newline at end of file diff --git a/src/ts/persona.ts b/src/ts/persona.ts index d0cd1fe2..8dceee80 100644 --- a/src/ts/persona.ts +++ b/src/ts/persona.ts @@ -27,11 +27,9 @@ export async function selectUserImg() { export function saveUserPersona() { let db = get(DataBase) - db.personas[db.selectedPersona] = { - name: db.username, - icon: db.userIcon, - personaPrompt: db.personaPrompt - } + db.personas[db.selectedPersona].name = db.username; + db.personas[db.selectedPersona].icon = db.userIcon; + db.personas[db.selectedPersona].personaPrompt = db.personaPrompt; setDatabase(db) } diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts index 7cfa0cc7..36ec1279 100644 --- a/src/ts/storage/database.ts +++ b/src/ts/storage/database.ts @@ -527,6 +527,7 @@ export interface Database{ personaPrompt:string name:string icon:string + largePortrait?:boolean }[] assetWidth:number animationSpeed:number From 61cdd2f5272d080259ea05749eed7fa62e6fe250 Mon Sep 17 00:00:00 2001 From: bangonicdd <157843588+bangonicdd2@users.noreply.github.com> Date: Sat, 3 Feb 2024 23:51:28 +0900 Subject: [PATCH 2/3] revert to original code style --- src/ts/persona.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ts/persona.ts b/src/ts/persona.ts index 8dceee80..2029b57d 100644 --- a/src/ts/persona.ts +++ b/src/ts/persona.ts @@ -27,9 +27,12 @@ export async function selectUserImg() { export function saveUserPersona() { let db = get(DataBase) - db.personas[db.selectedPersona].name = db.username; - db.personas[db.selectedPersona].icon = db.userIcon; - db.personas[db.selectedPersona].personaPrompt = db.personaPrompt; + db.personas[db.selectedPersona] = { + name: db.username, + icon: db.userIcon, + personaPrompt: db.personaPrompt, + largePortrait: db.personas[db.selectedPersona].largePortrait, + } setDatabase(db) } From 51dc0b193134c87dd8f21e02bc5a285acb4b4a8a Mon Sep 17 00:00:00 2001 From: bangonicdd <157843588+bangonicdd2@users.noreply.github.com> Date: Sun, 4 Feb 2024 00:10:36 +0900 Subject: [PATCH 3/3] avoid potential error just in case --- src/ts/persona.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/persona.ts b/src/ts/persona.ts index 2029b57d..c414d394 100644 --- a/src/ts/persona.ts +++ b/src/ts/persona.ts @@ -31,7 +31,7 @@ export function saveUserPersona() { name: db.username, icon: db.userIcon, personaPrompt: db.personaPrompt, - largePortrait: db.personas[db.selectedPersona].largePortrait, + largePortrait: db.personas[db.selectedPersona]?.largePortrait, } setDatabase(db) }