[feat] added features in spec v2
This commit is contained in:
@@ -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<START>\n{{user}}: hi\n{{char}}: hello\n<START>\n{{user}}: hi\nHaruhi: hello\n```"
|
||||
+ "\n\n```<START>``` 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"
|
||||
}
|
||||
|
||||
@@ -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)을 감정으로 정하고 감정 처리를 하지 않습니다.",
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
import { replacePlaceholders } from "../../ts/util";
|
||||
export let message = ''
|
||||
export let name = ''
|
||||
export let img = ''
|
||||
export let img:string|Promise<string> = ''
|
||||
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)
|
||||
</script>
|
||||
<div class="flex">
|
||||
<div class="flex max-w-full">
|
||||
<div class="text-neutral-200 mt-2 p-2 bg-transparent flex-grow ml-4 mr-4 border-t-gray-900 border-opacity-30 border-transparent flexium items-start">
|
||||
{#if img === ''}
|
||||
<div class="rounded-md shadow-lg bg-gray-500 mt-2" style={`height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`}>
|
||||
|
||||
</div>
|
||||
{:else}
|
||||
<div class="rounded-md shadow-lg bg-gray-500 mt-2" style={img + `height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`} />
|
||||
{/if}
|
||||
{#await img}
|
||||
<div class="rounded-md shadow-lg bg-gray-500 mt-2" style={`height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`} />
|
||||
{:then m}
|
||||
<div class="rounded-md shadow-lg bg-gray-500 mt-2" style={m + `height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem`} />
|
||||
{/await}
|
||||
<span class="flex flex-col ml-4 w-full">
|
||||
<div class="flexium items-center chat">
|
||||
<span class="chat text-xl unmargin">{name}</span>
|
||||
@@ -106,8 +105,8 @@
|
||||
<LanguagesIcon />
|
||||
</button>
|
||||
{/if}
|
||||
{#if rerollIcon}
|
||||
{#if $DataBase.swipe}
|
||||
{#if rerollIcon || altGreeting}
|
||||
{#if $DataBase.swipe || altGreeting}
|
||||
<button class="ml-2 hover:text-green-500 transition-colors" on:click={unReroll}>
|
||||
<ArrowLeft size={22}/>
|
||||
</button>
|
||||
|
||||
19
src/lib/ChatScreens/CreatorQuote.svelte
Normal file
19
src/lib/ChatScreens/CreatorQuote.svelte
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="flex w-full justify-center">
|
||||
<div class="w-3xl max-w-80p bg-darkbg rounded-md p-3 text-white text-sm">
|
||||
<h1 class="text-xl font-bold mb-2">Creator's Quote
|
||||
<button class="float-right" on:click={onRemove}>
|
||||
<XIcon />
|
||||
</button>
|
||||
</h1>
|
||||
<div class="ml-2 max-w-full break-words text chat chattext prose prose-invert">
|
||||
{@html ParseMarkdown(quote)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script lang="ts">
|
||||
import { XIcon } from "lucide-svelte";
|
||||
import { ParseMarkdown } from "src/ts/parser";
|
||||
|
||||
export let onRemove: () => void
|
||||
export let quote:string
|
||||
</script>
|
||||
@@ -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')}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={$DataBase.characters[$selectedCharID].name}
|
||||
message={chat.data}
|
||||
img={''}
|
||||
rerollIcon={i === 0}
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
/>
|
||||
{:then im}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={$DataBase.characters[$selectedCharID].name}
|
||||
message={chat.data}
|
||||
img={im}
|
||||
rerollIcon={i === 0}
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
|
||||
/>
|
||||
{/await}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={$DataBase.characters[$selectedCharID].name}
|
||||
message={chat.data}
|
||||
img={getCharImage($DataBase.characters[$selectedCharID].image, 'css')}
|
||||
rerollIcon={i === 0}
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
/>
|
||||
{:else}
|
||||
{#await getCharImage(findCharacterbyId(chat.saying).image, 'css')}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={findCharacterbyId(chat.saying).name}
|
||||
message={chat.data}
|
||||
rerollIcon={i === 0}
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
img={''}
|
||||
/>
|
||||
{:then im}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={findCharacterbyId(chat.saying).name}
|
||||
rerollIcon={i === 0}
|
||||
message={chat.data}
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
img={im}
|
||||
/>
|
||||
{/await}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={findCharacterbyId(chat.saying).name}
|
||||
rerollIcon={i === 0}
|
||||
message={chat.data}
|
||||
onReroll={reroll}
|
||||
unReroll={unReroll}
|
||||
img={getCharImage(findCharacterbyId(chat.saying).image, 'css')}
|
||||
/>
|
||||
{/if}
|
||||
{:else}
|
||||
{#await getCharImage($DataBase.userIcon, 'css')}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={$DataBase.username}
|
||||
message={chat.data}
|
||||
img={''}
|
||||
/>
|
||||
{:then im}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={$DataBase.username}
|
||||
message={chat.data}
|
||||
img={im}
|
||||
/>
|
||||
{/await}
|
||||
<Chat
|
||||
idx={chat.index}
|
||||
name={$DataBase.username}
|
||||
message={chat.data}
|
||||
img={getCharImage($DataBase.userIcon, 'css')}
|
||||
/>
|
||||
{/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')}
|
||||
<Chat
|
||||
name={$DataBase.characters[$selectedCharID].name}
|
||||
message={ $DataBase.characters[$selectedCharID].firstMessage}
|
||||
img={''}
|
||||
idx={-1}
|
||||
/>
|
||||
{:then im}
|
||||
<Chat
|
||||
name={$DataBase.characters[$selectedCharID].name}
|
||||
message={ $DataBase.characters[$selectedCharID].firstMessage}
|
||||
img={im}
|
||||
idx={-1}
|
||||
/>
|
||||
{/await}
|
||||
<Chat
|
||||
name={$DataBase.characters[$selectedCharID].name}
|
||||
message={$DataBase.characters[$selectedCharID].firstMsgIndex === -1 ? $DataBase.characters[$selectedCharID].firstMessage :
|
||||
$DataBase.characters[$selectedCharID].alternateGreetings[$DataBase.characters[$selectedCharID].firstMsgIndex]}
|
||||
img={getCharImage($DataBase.characters[$selectedCharID].image, 'css')}
|
||||
idx={-1}
|
||||
altGreeting={$DataBase.characters[$selectedCharID].alternateGreetings.length > 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}
|
||||
<CreatorQuote quote={$DataBase.characters[$selectedCharID].creatorNotes} onRemove={() => {
|
||||
const cha = $DataBase.characters[$selectedCharID]
|
||||
if(cha.type !== 'group'){
|
||||
cha.removedQuotes = true
|
||||
}
|
||||
$DataBase.characters[$selectedCharID] = cha
|
||||
}} />
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if openMenu}
|
||||
<div class="absolute right-2 bottom-16 p-5 bg-darkbg flex flex-col gap-3 text-gray-200" on:click={(e) => {
|
||||
e.stopPropagation()
|
||||
|
||||
@@ -5,15 +5,20 @@
|
||||
}}>
|
||||
{#if key === "experimental"}
|
||||
<FlaskConicalIcon size={14} />
|
||||
{:else if unrecommended}
|
||||
<div class="text-red-500 hover:text-green-500">
|
||||
<AlertTriangle size={14} />
|
||||
</div>
|
||||
{:else}
|
||||
<HelpCircleIcon size={14} />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<script lang="ts">
|
||||
import { FlaskConicalIcon, HelpCircleIcon } from "lucide-svelte";
|
||||
import { AlertTriangle, FlaskConicalIcon, HelpCircleIcon } from "lucide-svelte";
|
||||
import { language } from "src/lang";
|
||||
import { alertMd } from "src/ts/alert";
|
||||
|
||||
export let unrecommended = false
|
||||
export let key: (keyof (typeof language.help))
|
||||
</script>
|
||||
@@ -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 @@
|
||||
<span class="text-neutral-200">{language.firstMessage} <Help key="charFirstMessage"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.firstMessage}></textarea>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.firstMsg} {language.tokens}</span>
|
||||
<span class="text-neutral-200">{language.authorNote} <Help key="charNote"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 resize-none h-20 focus:bg-selected text-xs" autocomplete="off" bind:value={currentChar.data.postHistoryInstructions}></textarea>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.charaNote} {language.tokens}</span>
|
||||
|
||||
{:else}
|
||||
<input class="text-neutral-200 mt-2 mb-4 p-2 bg-transparent input-text text-xl focus:bg-selected" placeholder="Group Name" bind:value={currentChar.data.name}>
|
||||
<span class="text-neutral-200">{language.character}</span>
|
||||
@@ -191,11 +203,13 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<span class="text-neutral-200">{language.chatNotes} <Help key="charNote"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 resize-none h-20 focus:bg-selected text-xs" autocomplete="off" bind:value={currentChar.data.chats[currentChar.data.chatPage].note}></textarea>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.localNote} {language.tokens}</span>
|
||||
|
||||
|
||||
{/if}
|
||||
<span class="text-neutral-200">{language.authorNote} <Help key="charNote"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 resize-none h-20 focus:bg-selected text-xs" autocomplete="off" bind:value={currentChar.data.chats[currentChar.data.chatPage].note}></textarea>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.localNote} {language.tokens}</span>
|
||||
|
||||
|
||||
<div class="flex mt-6 items-center">
|
||||
<Check bind:check={$DataBase.jailbreakToggle}/>
|
||||
<span class="text-neutral-200 ml-2">{language.jailbreakToggle}</span>
|
||||
@@ -359,6 +373,30 @@
|
||||
{:else if subMenu === 2}
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.advancedSettings}</h2>
|
||||
{#if currentChar.type !== 'group'}
|
||||
<span class="text-neutral-200">{language.exampleMessage} <Help key="exampleMessage"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.exampleMessage}></textarea>
|
||||
|
||||
<span class="text-neutral-200">{language.creatorNotes} <Help key="creatorQuotes"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.creatorNotes} on:input={() => {
|
||||
currentChar.data.removedQuotes = false
|
||||
}}></textarea>
|
||||
|
||||
<span class="text-neutral-200">{language.systemPrompt} <Help key="systemPrompt"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.systemPrompt}></textarea>
|
||||
|
||||
<span class="text-neutral-200">{language.chatNotes} <Help key="chatNote"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 resize-none h-20 focus:bg-selected text-xs" autocomplete="off" bind:value={currentChar.data.chats[currentChar.data.chatPage].note}></textarea>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.localNote} {language.tokens}</span>
|
||||
|
||||
{#if $DataBase.showUnrecommended || currentChar.data.personality.length > 3}
|
||||
<span class="text-neutral-200">{language.personality} <Help key="personality" unrecommended/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.personality}></textarea>
|
||||
{/if}
|
||||
{#if $DataBase.showUnrecommended || currentChar.data.scenario.length > 3}
|
||||
<span class="text-neutral-200">{language.scenario} <Help key="scenario" unrecommended/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.scenario}></textarea>
|
||||
{/if}
|
||||
|
||||
<span class="text-neutral-200 mt-2">Bias <Help key="bias"/></span>
|
||||
<table class="contain w-full max-w-full tabler mt-2">
|
||||
<tr>
|
||||
@@ -374,7 +412,7 @@
|
||||
</tr>
|
||||
{#if currentChar.data.bias.length === 0}
|
||||
<tr>
|
||||
<div class="text-gray-500">{language.noBias}</div>
|
||||
<div class="text-gray-500"> {language.noBias}</div>
|
||||
</tr>
|
||||
{/if}
|
||||
{#each currentChar.data.bias as bias, i}
|
||||
@@ -395,6 +433,49 @@
|
||||
</tr>
|
||||
{/each}
|
||||
</table>
|
||||
|
||||
<span class="text-neutral-200 mt-2">{language.altGreet} <Help key="bias"/></span>
|
||||
<table class="contain w-full max-w-full tabler mt-2">
|
||||
<tr>
|
||||
<th class="font-medium">{language.value}</th>
|
||||
<th class="font-medium cursor-pointer w-10">
|
||||
<button class="hover:text-green-500" on:click={() => {
|
||||
if(currentChar.type === 'character'){
|
||||
let alternateGreetings = currentChar.data.alternateGreetings
|
||||
alternateGreetings.push('')
|
||||
currentChar.data.alternateGreetings = alternateGreetings
|
||||
}
|
||||
}}>
|
||||
<PlusIcon />
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
{#if currentChar.data.alternateGreetings.length === 0}
|
||||
<tr>
|
||||
<div class="text-gray-500"> No Messages</div>
|
||||
</tr>
|
||||
{/if}
|
||||
{#each currentChar.data.alternateGreetings as bias, i}
|
||||
<tr>
|
||||
<td class="font-medium truncate">
|
||||
<textarea class="text-neutral-200 mt-2 mb-4 p-2 bg-transparent input-text focus:bg-selected w-full resize-none" bind:value={currentChar.data.alternateGreetings[i]} placeholder="..." />
|
||||
</td>
|
||||
<th class="font-medium cursor-pointer w-10">
|
||||
<button class="hover:text-green-500" on:click={() => {
|
||||
if(currentChar.type === 'character'){
|
||||
currentChar.data.firstMsgIndex = -1
|
||||
let alternateGreetings = currentChar.data.alternateGreetings
|
||||
alternateGreetings.splice(i, 1)
|
||||
currentChar.data.alternateGreetings = alternateGreetings
|
||||
}
|
||||
}}>
|
||||
<TrashIcon />
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
{/each}
|
||||
</table>
|
||||
|
||||
<span class="text-neutral-200 mt-4">{language.regexScript} <Help key="regexScript"/></span>
|
||||
<table class="contain w-full max-w-full tabler mt-2 flex flex-col p-2 gap-2">
|
||||
{#if currentChar.data.customscript.length === 0}
|
||||
@@ -410,7 +491,7 @@
|
||||
}}/>
|
||||
{/each}
|
||||
</table>
|
||||
<th class="font-medium cursor-pointer hover:text-green-500" on:click={() => {
|
||||
<button class="font-medium cursor-pointer hover:text-green-500 mb-2" on:click={() => {
|
||||
if(currentChar.type === 'character'){
|
||||
let script = currentChar.data.customscript
|
||||
script.push({
|
||||
@@ -421,27 +502,14 @@
|
||||
})
|
||||
currentChar.data.customscript = script
|
||||
}
|
||||
}}><PlusIcon /></th>
|
||||
<div class="flex items-center mt-4">
|
||||
<Check bind:check={currentChar.data.utilityBot}/>
|
||||
<span>{language.utilityBot}</span>
|
||||
</div>
|
||||
|
||||
<span class="text-neutral-200">{language.exampleMessage}</span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.exampleMessage}></textarea>
|
||||
|
||||
<span class="text-neutral-200">{language.creatorNotes} <Help key="charFirstMessage"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.firstMessage}></textarea>
|
||||
|
||||
<span class="text-neutral-200">{language.systemPrompt} <Help key="charFirstMessage"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.firstMessage}></textarea>
|
||||
|
||||
<span class="text-neutral-200">{language.characterNotes} <Help key="charFirstMessage"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.firstMessage}></textarea>
|
||||
|
||||
<span class="text-neutral-200">{language.personality} <Help key="charFirstMessage"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 text-xs resize-none h-20 focus:bg-selected" autocomplete="off" bind:value={currentChar.data.firstMessage}></textarea>
|
||||
|
||||
}}><PlusIcon /></button>
|
||||
|
||||
{#if $DataBase.showUnrecommended || currentChar.data.utilityBot}
|
||||
<div class="flex items-center mt-4">
|
||||
<Check bind:check={currentChar.data.utilityBot}/>
|
||||
<span>{language.utilityBot} <Help key="utilityBot" unrecommended/></span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<button on:click={async () => {
|
||||
exportChar($selectedCharID)
|
||||
@@ -449,10 +517,10 @@
|
||||
|
||||
{:else}
|
||||
|
||||
<div class="flex mb-2 items-center">
|
||||
<Check bind:check={currentChar.data.useCharacterLore}/>
|
||||
<span class="text-neutral-200 ml-2">{language.useCharLorebook} <Help key="experimental"/></span>
|
||||
</div>
|
||||
<div class="flex mb-2 items-center">
|
||||
<Check bind:check={currentChar.data.useCharacterLore}/>
|
||||
<span class="text-neutral-200 ml-2">{language.useCharLorebook} <Help key="experimental"/></span>
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
<button on:click={async () => {
|
||||
|
||||
@@ -499,7 +499,10 @@
|
||||
<Check bind:check={$DataBase.useSayNothing}/>
|
||||
<span>{language.sayNothing}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-4">
|
||||
<Check bind:check={$DataBase.showUnrecommended}/>
|
||||
<span>{language.showUnrecommended}</span>
|
||||
</div>
|
||||
<button
|
||||
on:click={async () => {
|
||||
alertMd(getRequestLog())
|
||||
|
||||
@@ -47,6 +47,7 @@ html, body{
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
/* Track */
|
||||
|
||||
@@ -192,6 +192,7 @@ function convertOldTavernAndJSON(charaData:OldTavernChar, imgp:string|undefined
|
||||
characterVersion: 0,
|
||||
personality: charaData.personality ?? '',
|
||||
scenario:charaData.scenario ?? '',
|
||||
firstMsgIndex: -1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,6 +351,8 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array):Promise<boole
|
||||
characterVersion: data.character_version ?? 0,
|
||||
personality:data.personality ?? '',
|
||||
scenario:data.scenario ?? '',
|
||||
firstMsgIndex: -1,
|
||||
removedQuotes: false
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ export function createNewGroup(){
|
||||
emotionImages: [],
|
||||
customscript: [],
|
||||
chaId: uuidv4(),
|
||||
firstMsgIndex: -1
|
||||
})
|
||||
setDatabase(db)
|
||||
return db.characters.length - 1
|
||||
@@ -269,6 +270,18 @@ export function characterFormatUpdate(index:number|character){
|
||||
if(checkNullish(cha.utilityBot)){
|
||||
cha.utilityBot = false
|
||||
}
|
||||
cha.alternateGreetings = cha.alternateGreetings ?? []
|
||||
cha.exampleMessage = cha.exampleMessage ?? ''
|
||||
cha.creatorNotes = cha.creatorNotes ?? ''
|
||||
cha.systemPrompt = cha.systemPrompt ?? ''
|
||||
cha.postHistoryInstructions = cha.postHistoryInstructions ?? ''
|
||||
cha.tags = cha.tags ?? []
|
||||
cha.creator = cha.creator ?? ''
|
||||
cha.characterVersion = cha.characterVersion ?? 0
|
||||
cha.personality = cha.personality ?? ''
|
||||
cha.scenario = cha.scenario ?? ''
|
||||
cha.firstMsgIndex = cha.firstMsgIndex ?? -1
|
||||
|
||||
}
|
||||
if(checkNullish(cha.customscript)){
|
||||
cha.customscript = []
|
||||
@@ -313,6 +326,7 @@ export function createBlankChar():character{
|
||||
characterVersion: 0,
|
||||
personality:"",
|
||||
scenario:"",
|
||||
firstMsgIndex: -1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,9 @@ export function setDatabase(data:Database){
|
||||
if(checkNullish(data.requestproxy)){
|
||||
data.requestproxy = ''
|
||||
}
|
||||
if(checkNullish(data.showUnrecommended)){
|
||||
data.showUnrecommended = false
|
||||
}
|
||||
if(checkNullish(data.sdConfig)){
|
||||
data.sdConfig = {
|
||||
width:512,
|
||||
@@ -238,7 +241,7 @@ export interface character{
|
||||
customscript: customscript[]
|
||||
utilityBot: boolean
|
||||
exampleMessage:string
|
||||
|
||||
removedQuotes?:boolean
|
||||
creatorNotes:string
|
||||
systemPrompt:string
|
||||
postHistoryInstructions:string
|
||||
@@ -248,6 +251,7 @@ export interface character{
|
||||
characterVersion: number
|
||||
personality:string
|
||||
scenario:string
|
||||
firstMsgIndex:number
|
||||
}
|
||||
|
||||
export interface groupChat{
|
||||
@@ -265,6 +269,10 @@ export interface groupChat{
|
||||
emotionImages: [string, string][]
|
||||
customscript: customscript[],
|
||||
chaId: string
|
||||
alternateGreetings?: string[]
|
||||
creatorNotes?:string,
|
||||
removedQuotes?:boolean
|
||||
firstMsgIndex?:number,
|
||||
}
|
||||
|
||||
export interface botPreset{
|
||||
@@ -358,6 +366,7 @@ export interface Database{
|
||||
didFirstSetup: boolean
|
||||
requestmet: string
|
||||
requestproxy: string
|
||||
showUnrecommended:boolean
|
||||
}
|
||||
|
||||
|
||||
|
||||
62
src/ts/process/exampleMessages.ts
Normal file
62
src/ts/process/exampleMessages.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import type { OpenAIChat } from ".";
|
||||
import type { character } from "../database";
|
||||
import { replacePlaceholders } from "../util";
|
||||
|
||||
export function exampleMessage(char:character):OpenAIChat[]{
|
||||
if(char.exampleMessage === ''){
|
||||
return []
|
||||
}
|
||||
|
||||
const messages = char.exampleMessage.split('\n')
|
||||
let result:OpenAIChat[] = []
|
||||
let currentMessage:OpenAIChat
|
||||
|
||||
function add(){
|
||||
if(currentMessage){
|
||||
result.push(currentMessage)
|
||||
}
|
||||
}
|
||||
|
||||
for(const mes of messages){
|
||||
const trimed = mes.trim()
|
||||
const lowered = trimed.toLocaleLowerCase()
|
||||
|
||||
|
||||
if(lowered === '<start>'){
|
||||
add()
|
||||
result.push({
|
||||
role: "system",
|
||||
content: '[Start a new chat]'
|
||||
})
|
||||
}
|
||||
else if(lowered.startsWith('{{char}}:') || lowered.startsWith('<bot>:') || lowered.startsWith(`${char.name}:`)){
|
||||
add()
|
||||
currentMessage = {
|
||||
role: "assistant",
|
||||
content: trimed.split(':', 2)[1]
|
||||
}
|
||||
}
|
||||
else if(lowered.startsWith('{{user}}:') || lowered.startsWith('<user>:')){
|
||||
add()
|
||||
currentMessage = {
|
||||
role: "user",
|
||||
content: trimed.split(':', 2)[1]
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(currentMessage){
|
||||
currentMessage.content += "\n" + trimed
|
||||
}
|
||||
}
|
||||
}
|
||||
add()
|
||||
|
||||
result = result.map((r) => {
|
||||
return {
|
||||
role: r.role,
|
||||
content: replacePlaceholders(r.content, char.name)
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { findCharacterbyId, replacePlaceholders } from "../util";
|
||||
import { requestChatData } from "./request";
|
||||
import { stableDiff } from "./stableDiff";
|
||||
import { processScript, processScriptFull } from "./scripts";
|
||||
import { exampleMessage } from "./exampleMessages";
|
||||
|
||||
export interface OpenAIChat{
|
||||
role: 'system'|'user'|'assistant'
|
||||
@@ -99,9 +100,11 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
||||
}
|
||||
|
||||
if(!currentChar.utilityBot){
|
||||
const mainp = currentChar.systemPrompt.length > 3 ? currentChar.systemPrompt : db.mainPrompt
|
||||
|
||||
unformated.main.push({
|
||||
role: 'system',
|
||||
content: replacePlaceholders(db.mainPrompt + ((db.additionalPrompt === '' || (!db.promptPreprocess)) ? '' : `\n${db.additionalPrompt}`), currentChar.name)
|
||||
content: replacePlaceholders(mainp + ((db.additionalPrompt === '' || (!db.promptPreprocess)) ? '' : `\n${db.additionalPrompt}`), currentChar.name)
|
||||
})
|
||||
|
||||
if(db.jailbreakToggle){
|
||||
@@ -122,10 +125,30 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
||||
content: replacePlaceholders(currentChat.note, currentChar.name)
|
||||
})
|
||||
|
||||
unformated.description.push({
|
||||
role: 'system',
|
||||
content: replacePlaceholders((db.promptPreprocess ? db.descriptionPrefix: '') + currentChar.desc, currentChar.name)
|
||||
})
|
||||
if(currentChar.postHistoryInstructions !== ''){
|
||||
unformated.authorNote.push({
|
||||
role: 'system',
|
||||
content: replacePlaceholders(currentChar.postHistoryInstructions, currentChar.name)
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
let description = replacePlaceholders((db.promptPreprocess ? db.descriptionPrefix: '') + currentChar.desc, currentChar.name)
|
||||
|
||||
if(currentChar.personality){
|
||||
description += replacePlaceholders("\n\nDescription of {{char}}: " + currentChar.personality,currentChar.name)
|
||||
}
|
||||
|
||||
if(currentChar.scenario){
|
||||
description += replacePlaceholders("\n\nCircumstances and context of the dialogue: " + currentChar.scenario,currentChar.name)
|
||||
}
|
||||
|
||||
unformated.description.push({
|
||||
role: 'system',
|
||||
content: description
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
unformated.lorebook.push({
|
||||
role: 'system',
|
||||
@@ -139,20 +162,12 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
||||
}).join('\n\n')
|
||||
}).join('\n\n')) + db.maxResponse) + 150
|
||||
|
||||
let chats:OpenAIChat[] = []
|
||||
let chats:OpenAIChat[] = exampleMessage(currentChar)
|
||||
|
||||
if(nowChatroom.type === 'group'){
|
||||
chats.push({
|
||||
role: 'system',
|
||||
content: '[Start a new group chat]'
|
||||
})
|
||||
}
|
||||
else{
|
||||
chats.push({
|
||||
role: 'system',
|
||||
content: '[Start a new chat]'
|
||||
})
|
||||
}
|
||||
chats.push({
|
||||
role: 'system',
|
||||
content: '[Start a new chat]'
|
||||
})
|
||||
|
||||
chats.push({
|
||||
role: 'assistant',
|
||||
@@ -349,25 +364,6 @@ export async function sendChat(chatProcessIndex = -1):Promise<boolean> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// const promptbody:OpenAIChat[] = [
|
||||
// {
|
||||
|
||||
// role:'system',
|
||||
// content: `assistant is a emotion extractor. user will input a prompt of a character, and assistant must output the emotion of a character.\n\n must chosen from this list: ${shuffleArray(emotionList).join(', ')} \noutput only one word.`
|
||||
// },
|
||||
// {
|
||||
// role: 'user',
|
||||
// content: `"Good morning, Master! Is there anything I can do for you today?"`
|
||||
// },
|
||||
// {
|
||||
// role: 'assistant',
|
||||
// content: 'happy'
|
||||
// },
|
||||
// {
|
||||
// role: 'user',
|
||||
// content: result
|
||||
// },
|
||||
// ]
|
||||
|
||||
const promptbody:OpenAIChat[] = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user