From c4d44d20319a59e4ec6f6d6c8274ceb44c66efcb Mon Sep 17 00:00:00 2001 From: kwaroran Date: Fri, 12 May 2023 20:14:03 +0900 Subject: [PATCH] [feat] added features in spec v2 --- src/lang/en.ts | 24 +++- src/lang/ko.ts | 2 +- src/lib/ChatScreens/Chat.svelte | 21 ++- src/lib/ChatScreens/CreatorQuote.svelte | 19 +++ src/lib/ChatScreens/DefaultChatScreen.svelte | 140 +++++++++---------- src/lib/Others/Help.svelte | 7 +- src/lib/SideBars/CharConfig.svelte | 134 +++++++++++++----- src/lib/SideBars/Settings.svelte | 5 +- src/styles.css | 1 + src/ts/characterCards.ts | 3 + src/ts/characters.ts | 14 ++ src/ts/database.ts | 11 +- src/ts/process/exampleMessages.ts | 62 ++++++++ src/ts/process/index.ts | 70 +++++----- tailwind.config.js | 2 + 15 files changed, 353 insertions(+), 162 deletions(-) create mode 100644 src/lib/ChatScreens/CreatorQuote.svelte create mode 100644 src/ts/process/exampleMessages.ts diff --git a/src/lang/en.ts b/src/lang/en.ts index c84f71b0..01da7459 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -35,7 +35,7 @@ export const languageEnglish = { msgSound: "Plays *ding* sound when character responses", charDesc: "Brief description of the character. this effects characters response.", charFirstMessage: "First message of the character. this highly effects characters response.", - charNote: "a note that strongly effects model behavior. works in current chat. also known as memory.", + charNote: "a note that strongly effects model behavior. embbedded to current character. also known as UJB.", toggleNsfw: "toggles NSFW/jailbreak prompt on and off.", lorebook: "Lorebook is a user-made dictionary for AI. AI only sees it when where is an activation keys in the context.", loreName: "name of the lore. it dosen't effects the Ai.", @@ -54,13 +54,24 @@ export const languageEnglish = { regexScript: "Regex Script is a custom script that is embbedded to the character. it replaces string that matches IN to OUT.\n\nThere are three type options." + "- **Modify Input** modifys user's input" + "- **Modify Output** modifys character's output" - + "- **Modify Request Data** modifys current chat data when sent.\n\nIN must be a regex without flags and *\\*.\n\nOUT is a normal string." + + "- **Modify Request Data** modifys current chat data when sent.\n\nIN must be a regex without flags and without backslashes in start and end.\n\nOUT is a normal string." + "\n\n If OUT has {{data}} in string, it replaces to matched string." + "\n\n If OUT starts with **@@**, it doesn't replaces the string, but instead does a special effect if matching string founds." + "\n\n- @@emo (emotion name)\n\n if character is Emotion Images mode, sets (emotion name) as emotion and prevents default.", experimental: "This is a experimental setting. it might be unstable.", oogaboogaURL: "If your WebUI supports older version of api, your url should look *like https:.../run/textgen*\n\n" - + "If your WebUI supports newVersion of api, your url should look like *https://.../api/v1/generate* and use the api server as host, and add --api to arguments." + + "If your WebUI supports newVersion of api, your url should look like *https://.../api/v1/generate* and use the api server as host, and add --api to arguments.", + exampleMessage: "Example conversations that effects output of the character. it dosen't uses tokens permanently." + + "\n\nExample format of conversations:" + + "\n\n```\n\n{{user}}: hi\n{{char}}: hello\n\n{{user}}: hi\nHaruhi: hello\n```" + + "\n\n`````` Marks the beginning of a new conversation.", + creatorQuotes: "Quote that appearances on top of first message. Used to inform users about this character. It doesn't go into prompt.", + systemPrompt: "A prompt that replaces main prompt in settings if its not blank.", + chatNote: "a note that strongly effects model behavior. embbedded to current chat. also known as memory.", + personality: "A brief description about character's personality. \n\n**It is not recommended to use this option. Describe it in character description instead.**", + scenario: "A brief description about character's scenario. \n\n**It is not recommended to use this option. Describe it in character description instead.**", + utilityBot: "When activated, it ignores main prompt. \n\n**It is not recommended to use this option. Modifiy system prompt instead.**" + }, setup: { chooseProvider: "Choose AI Provider", @@ -217,5 +228,10 @@ export const languageEnglish = { systemPrompt: "System Prompt", characterNotes: "Character Notes", personality: "Personality", - alternateGreetings: "Alternate Greetings" + scenario: "Scenario", + alternateGreetings: "Alternate Greetings", + unrecommended: "Not Recommended", + chatNotes: "Chat Notes", + showUnrecommended: "Show Unrecommended Settings", + altGreet: "Alternative First Messages" } diff --git a/src/lang/ko.ts b/src/lang/ko.ts index 63adc1ee..428daccf 100644 --- a/src/lang/ko.ts +++ b/src/lang/ko.ts @@ -183,7 +183,7 @@ export const languageKorean = { regexScript: "정규식 스크립트는 캐릭터에 종속된 커스텀 스크립트입니다. IN의 조건에 맞는 문자열을 OUT으로 변경합니다.\n\n타입은 세가지가 있습니다." + "- **입력문 수정** 유저의 입력문을 수정합니다" + "- **출력문 수정** 캐릭터의 출력문을 수정합니다" - + "- **리퀘스트 데이터 수정** 리퀘스트를 보낼 때 채팅 데이터를 수정합니다.\n\nIN은 flag와 *\\* 가 없는 Regex여야 합니다.\n\nOUT은 일반 문자열입니다." + + "- **리퀘스트 데이터 수정** 리퀘스트를 보낼 때 채팅 데이터를 수정합니다.\n\nIN은 flag가 없고, 양끝에 백슬레시가 없는 Regex여야 합니다.\n\nOUT은 일반 문자열입니다." + "\n\n 만약 OUT 문자열에 {{data}}가 있으면, 매칭된 문자열로 바뀝니다." + "\n\n 만약 OUT이 @@로 시작된다면, 특수한 효과를 냅니다" + "\n\n- @@emo (emotion name)\n\n 감정 이미지 모드일 시 (emotion name)을 감정으로 정하고 감정 처리를 하지 않습니다.", diff --git a/src/lib/ChatScreens/Chat.svelte b/src/lib/ChatScreens/Chat.svelte index eb7f86f9..96ecfd44 100644 --- a/src/lib/ChatScreens/Chat.svelte +++ b/src/lib/ChatScreens/Chat.svelte @@ -10,13 +10,14 @@ import { replacePlaceholders } from "../../ts/util"; export let message = '' export let name = '' - export let img = '' + export let img:string|Promise = '' export let idx = -1 export let rerollIcon = false export let onReroll = () => {} export let unReroll = () => {} let translating = false let editMode = false + export let altGreeting = false let msgDisplay = '' @@ -60,15 +61,13 @@ $: displaya(message) -
+
- {#if img === ''} -
- -
- {:else} -
- {/if} + {#await img} +
+ {:then m} +
+ {/await}
{name} @@ -106,8 +105,8 @@ {/if} - {#if rerollIcon} - {#if $DataBase.swipe} + {#if rerollIcon || altGreeting} + {#if $DataBase.swipe || altGreeting} diff --git a/src/lib/ChatScreens/CreatorQuote.svelte b/src/lib/ChatScreens/CreatorQuote.svelte new file mode 100644 index 00000000..ace3b5c8 --- /dev/null +++ b/src/lib/ChatScreens/CreatorQuote.svelte @@ -0,0 +1,19 @@ +
+
+

Creator's Quote + +

+
+ {@html ParseMarkdown(quote)} +
+
+
+ \ No newline at end of file diff --git a/src/lib/ChatScreens/DefaultChatScreen.svelte b/src/lib/ChatScreens/DefaultChatScreen.svelte index f41ae962..937cf5b0 100644 --- a/src/lib/ChatScreens/DefaultChatScreen.svelte +++ b/src/lib/ChatScreens/DefaultChatScreen.svelte @@ -13,6 +13,7 @@ import {cloneDeep} from 'lodash' import { processScript } from "src/ts/process/scripts"; import GithubStars from "../Others/GithubStars.svelte"; + import CreatorQuote from "./CreatorQuote.svelte"; let messageInput = '' let openMenu = false @@ -237,88 +238,81 @@ {#each messageForm($DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].message, loadPages) as chat, i} {#if chat.role === 'char'} {#if $DataBase.characters[$selectedCharID].type !== 'group'} - {#await getCharImage($DataBase.characters[$selectedCharID].image, 'css')} - - {:then im} - - {/await} + {:else} - {#await getCharImage(findCharacterbyId(chat.saying).image, 'css')} - - {:then im} - - {/await} + {/if} {:else} - {#await getCharImage($DataBase.userIcon, 'css')} - - {:then im} - - {/await} + {/if} {/each} {#if $DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].message.length <= loadPages} {#if $DataBase.characters[$selectedCharID].type !== 'group'} - {#await getCharImage($DataBase.characters[$selectedCharID].image, 'css')} - - {:then im} - - {/await} + 0} + onReroll={() => { + const cha = $DataBase.characters[$selectedCharID] + if(cha.type !== 'group'){ + if (cha.firstMsgIndex >= (cha.alternateGreetings.length - 1)){ + cha.firstMsgIndex = -1 + } + else{ + cha.firstMsgIndex += 1 + } + } + $DataBase.characters[$selectedCharID] = cha + }} + unReroll={() => { + const cha = $DataBase.characters[$selectedCharID] + if(cha.type !== 'group'){ + if (cha.firstMsgIndex === -1){ + cha.firstMsgIndex = (cha.alternateGreetings.length - 1) + } + else{ + cha.firstMsgIndex -= 1 + } + } + $DataBase.characters[$selectedCharID] = cha + }} + /> + {#if !$DataBase.characters[$selectedCharID].removedQuotes && $DataBase.characters[$selectedCharID].creatorNotes.length >= 2} + { + const cha = $DataBase.characters[$selectedCharID] + if(cha.type !== 'group'){ + cha.removedQuotes = true + } + $DataBase.characters[$selectedCharID] = cha + }} /> + {/if} {/if} {/if} + {#if openMenu}
{ e.stopPropagation() diff --git a/src/lib/Others/Help.svelte b/src/lib/Others/Help.svelte index e8e91b1e..3c2c11d7 100644 --- a/src/lib/Others/Help.svelte +++ b/src/lib/Others/Help.svelte @@ -5,15 +5,20 @@ }}> {#if key === "experimental"} + {:else if unrecommended} +
+ +
{:else} {/if} \ No newline at end of file diff --git a/src/lib/SideBars/CharConfig.svelte b/src/lib/SideBars/CharConfig.svelte index bae9aba4..ceb3b73f 100644 --- a/src/lib/SideBars/CharConfig.svelte +++ b/src/lib/SideBars/CharConfig.svelte @@ -22,13 +22,15 @@ let tokens = { desc: 0, firstMsg: 0, - localNote: 0 + localNote: 0, + charaNote: 0 } let lasttokens = { desc: '', firstMsg: '', - localNote: '' + localNote: '', + charaNote: '' } async function loadTokenize(chara){ @@ -45,12 +47,18 @@ lasttokens.firstMsg = chara.firstMessage tokens.firstMsg = await tokenize(chara.firstMessage) } + if(lasttokens.charaNote !== chara.postHistoryInstructions){ + lasttokens.charaNote = chara.postHistoryInstructions + tokens.charaNote = await tokenize(chara.postHistoryInstructions) + + } } if(lasttokens.localNote !== currentChar.data.chats[currentChar.data.chatPage].note){ lasttokens.localNote = currentChar.data.chats[currentChar.data.chatPage].note tokens.localNote = await tokenize(currentChar.data.chats[currentChar.data.chatPage].note) } + } @@ -163,6 +171,10 @@ {language.firstMessage} {tokens.firstMsg} {language.tokens} + {language.authorNote} + + {tokens.charaNote} {language.tokens} + {:else} {language.character} @@ -191,11 +203,13 @@
+ {language.chatNotes} + + {tokens.localNote} {language.tokens} + + {/if} - {language.authorNote} - - {tokens.localNote} {language.tokens} - +
{language.jailbreakToggle} @@ -359,6 +373,30 @@ {:else if subMenu === 2}

{language.advancedSettings}

{#if currentChar.type !== 'group'} + {language.exampleMessage} + + + {language.creatorNotes} + + + {language.systemPrompt} + + + {language.chatNotes} + + {tokens.localNote} {language.tokens} + + {#if $DataBase.showUnrecommended || currentChar.data.personality.length > 3} + {language.personality} + + {/if} + {#if $DataBase.showUnrecommended || currentChar.data.scenario.length > 3} + {language.scenario} + + {/if} + Bias @@ -374,7 +412,7 @@ {#if currentChar.data.bias.length === 0} -
{language.noBias}
+
{language.noBias}
{/if} {#each currentChar.data.bias as bias, i} @@ -395,6 +433,49 @@ {/each}
+ + {language.altGreet} + + + + + + {#if currentChar.data.alternateGreetings.length === 0} + +
No Messages
+ + {/if} + {#each currentChar.data.alternateGreetings as bias, i} + +
{language.value} + +
+ - - {language.creatorNotes} - - - {language.systemPrompt} - - - {language.characterNotes} - - - {language.personality} - - + }}> + + {#if $DataBase.showUnrecommended || currentChar.data.utilityBot} +
+ + {language.utilityBot} +
+ {/if}