[UX] settings close floating button, fix tokens position auto suggest prompt, AutoSuggest minor bugs (#149)
# PR Checklist - [ - ] Did you check if it works normally in all models? *ignore this when it dosen't uses models* - [ O ] Did you check if it works normally in all of web, local and node hosted versions? if it dosen't, did you blocked it in those versions? - [ O ] Did you added a type def? # Description There are many users who can't find the character deletion, so it has been changed so that it is clearly visible in the header.   It is inconvenient to scroll up and close the long settings window when scrolling, so it is fixed at the top.  Modify tokens count position not moved together auto suggest prompt.  Fixed the problem that auto-suggestion does not work for firstMessage Fixed the problem that auto-suggestion is not saved
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { requestChatData } from "src/ts/process/request";
|
||||
import { requestChatData } from "src/ts/process/request";
|
||||
import { doingChat, type OpenAIChat } from "../../ts/process/index";
|
||||
import { DataBase, type character } from "../../ts/storage/database";
|
||||
import { DataBase, setDatabase, type character, type Message, type groupChat, type Database } from "../../ts/storage/database";
|
||||
import { selectedCharID } from "../../ts/stores";
|
||||
import { translate } from "src/ts/translator/translator";
|
||||
import { CopyIcon, LanguagesIcon, RefreshCcwIcon } from "lucide-svelte";
|
||||
@@ -9,12 +9,14 @@
|
||||
import { language } from "src/lang";
|
||||
import { replacePlaceholders } from "../../ts/util";
|
||||
import { onDestroy } from 'svelte';
|
||||
import { processScript } from "src/ts/process/scripts";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
export let send: () => any;
|
||||
export let messageInput:(string:string) => any;
|
||||
let suggestMessages = $DataBase.characters[$selectedCharID]?.chats[$DataBase.characters[$selectedCharID].chatPage]?.suggestMessages
|
||||
let suggestMessages:string[] = $DataBase.characters[$selectedCharID]?.chats[$DataBase.characters[$selectedCharID].chatPage]?.suggestMessages
|
||||
let suggestMessagesTranslated:string[]
|
||||
let toggleTranslate = $DataBase.autoTranslate
|
||||
let toggleTranslate:boolean = $DataBase.autoTranslate
|
||||
let progress:boolean;
|
||||
let progressChatPage=-1;
|
||||
let abortController:AbortController;
|
||||
@@ -45,9 +47,20 @@
|
||||
suggestMessages = []
|
||||
}
|
||||
if(!v && $selectedCharID > -1 && (!suggestMessages || suggestMessages.length === 0) && !progress){
|
||||
let currentChar = $DataBase.characters[$selectedCharID] as character;
|
||||
let messages = currentChar.chats[currentChar.chatPage].message;
|
||||
let lastMessages = messages.slice(Math.max(messages.length - 10, 0));
|
||||
let currentChar:character|groupChat = $DataBase.characters[$selectedCharID];
|
||||
let messages:Message[] = []
|
||||
|
||||
if(currentChar.type !== 'group'){
|
||||
const firstMsg:string = currentChar.firstMsgIndex === -1 ? currentChar.firstMessage : currentChar.alternateGreetings[currentChar.firstMsgIndex]
|
||||
messages.push({
|
||||
role: 'char',
|
||||
data: processScript(currentChar,
|
||||
replacePlaceholders(firstMsg, currentChar.name),
|
||||
'editprocess')
|
||||
})
|
||||
}
|
||||
messages = [...messages, ...currentChar.chats[currentChar.chatPage].message];
|
||||
let lastMessages:Message[] = messages.slice(Math.max(messages.length - 10, 0));
|
||||
if(lastMessages.length === 0)
|
||||
return
|
||||
const promptbody:OpenAIChat[] = [
|
||||
@@ -58,7 +71,7 @@
|
||||
,
|
||||
{
|
||||
role: 'user',
|
||||
content: lastMessages.map(b=>b.role+":"+b.data).reduce((a,b)=>a+','+b)
|
||||
content: lastMessages.map(b=>(b.role==='char'? 'assistant' : 'user')+":"+b.data).reduce((a,b)=>a+','+b)
|
||||
}
|
||||
]
|
||||
|
||||
@@ -68,11 +81,13 @@
|
||||
requestChatData({
|
||||
formated: promptbody,
|
||||
bias: {},
|
||||
currentChar
|
||||
currentChar : currentChar as character
|
||||
}, 'submodel', abortController.signal).then(rq2=>{
|
||||
if(rq2.type !== 'fail' && rq2.type !== 'streaming' && progress){
|
||||
var suggestMessagesNew = rq2.result.split('\n').filter(msg => msg.startsWith('-')).map(msg => msg.replace('-','').trim())
|
||||
currentChar.chats[currentChar.chatPage].suggestMessages = suggestMessagesNew
|
||||
const db:Database = get(DataBase);
|
||||
db.characters[$selectedCharID].chats[currentChar.chatPage].suggestMessages = suggestMessagesNew
|
||||
setDatabase(db)
|
||||
suggestMessages = suggestMessagesNew
|
||||
}
|
||||
progress = false
|
||||
|
||||
@@ -147,7 +147,6 @@
|
||||
<span class="text-neutral-200">{language.globalNote} <Help key="globalNote"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 resize-none h-20 min-h-20 focus:bg-selected text-xs w-full" autocomplete="off" bind:value={$DataBase.globalNote}></textarea>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.globalNote} {language.tokens}</span>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.autoSuggest} {language.tokens}</span>
|
||||
|
||||
<span class="text-neutral-200">{language.maxContextSize}</span>
|
||||
{#if $DataBase.aiModel === 'gpt35'}
|
||||
@@ -175,8 +174,9 @@
|
||||
<input class="text-neutral-200 p-2 bg-transparent input-text focus:bg-selected text-sm"bind:value={$DataBase.forceReplaceUrl} placeholder="Leave blank to not replace url">
|
||||
<span class="text-neutral-200 mt-2">{language.submodel} {language.forceReplaceUrl} <Help key="forceUrl"/></span>
|
||||
<input class="text-neutral-200 p-2 bg-transparent input-text focus:bg-selected text-sm"bind:value={$DataBase.forceReplaceUrl2} placeholder="Leave blank to not replace url">
|
||||
<span class="text-neutral-200">{language.autoSuggest} <Help key="autoSuggest"/></span>
|
||||
<textarea class="bg-transparent input-text mt-2 mb-2 text-gray-200 resize-none h-20 min-h-20 focus:bg-selected text-xs w-full" autocomplete="off" bind:value={$DataBase.autoSuggestPrompt}></textarea>
|
||||
<span class="text-neutral-200 mt-2">{language.autoSuggest} <Help key="autoSuggest"/></span>
|
||||
<textarea class="bg-transparent input-text mb-2 text-gray-200 resize-none h-20 min-h-20 focus:bg-selected text-xs w-full" autocomplete="off" bind:value={$DataBase.autoSuggestPrompt}></textarea>
|
||||
<span class="text-gray-400 mb-6 text-sm">{tokens.autoSuggest} {language.tokens}</span>
|
||||
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
</script>
|
||||
<div class="h-full w-full flex justify-center setting-bg">
|
||||
<div class="h-full max-w-screen-lg w-full flex">
|
||||
<div class="h-full max-w-screen-lg w-full flex relative">
|
||||
{#if window.innerWidth >= 700 || selected === -1}
|
||||
<div class="flex h-full flex-col p-4 pt-8 bg-darkbg gap-2 overflow-y-auto relative"
|
||||
class:w-full={window.innerWidth < 700}>
|
||||
@@ -135,17 +135,17 @@
|
||||
{:else if selected === 11}
|
||||
<AccessibilitySettings/>
|
||||
{/if}
|
||||
<button class="absolute top-2 right-2 hover:text-green-500" on:click={() => {
|
||||
if(window.innerWidth >= 700){
|
||||
settingsOpen.set(false)
|
||||
}
|
||||
else{
|
||||
selected = -1
|
||||
}
|
||||
}}>
|
||||
<XCircleIcon />
|
||||
</button>
|
||||
</div>
|
||||
<button class="absolute top-2 right-2 hover:text-green-500 text-white" on:click={() => {
|
||||
if(window.innerWidth >= 700){
|
||||
settingsOpen.set(false)
|
||||
}
|
||||
else{
|
||||
selected = -1
|
||||
}
|
||||
}}>
|
||||
<XCircleIcon />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user