Add request info inside chat feature

This commit is contained in:
kwaroran
2024-03-19 02:43:39 +09:00
parent 0dce52ee7b
commit bdfdf5141a
6 changed files with 35 additions and 7 deletions

View File

@@ -540,4 +540,5 @@ export const languageEnglish = {
persistentStorageDesc: "Your browser supports persistent storage. this is recommended for better performance and user experience.",
enable: "Enable",
postFile: "Post File",
requestInfoInsideChat: "Show Request Info Inside Chat",
}

View File

@@ -1,16 +1,17 @@
<script lang="ts">
import { ArrowLeft, ArrowRight, PencilIcon, LanguagesIcon, RefreshCcwIcon, TrashIcon, CopyIcon, Volume2Icon } from "lucide-svelte";
import { ArrowLeft, ArrowRight, PencilIcon, LanguagesIcon, RefreshCcwIcon, TrashIcon, CopyIcon, Volume2Icon, BotIcon } from "lucide-svelte";
import { ParseMarkdown, type simpleCharacterArgument } from "../../ts/parser";
import AutoresizeArea from "../UI/GUI/TextAreaResizable.svelte";
import { alertConfirm, alertError } from "../../ts/alert";
import { language } from "../../lang";
import { DataBase, type groupChat } from "../../ts/storage/database";
import { CurrentCharacter, CurrentChat, selectedCharID } from "../../ts/stores";
import { translate, translateHTML } from "../../ts/translator/translator";
import { DataBase, type MessageGenerationInfo } from "../../ts/storage/database";
import { CurrentCharacter, CurrentChat } from "../../ts/stores";
import { translateHTML } from "../../ts/translator/translator";
import { risuChatParser } from "src/ts/process/scripts";
import { get } from "svelte/store";
import { isEqual } from "lodash";
import { sayTTS } from "src/ts/process/tts";
import { capitalize, isEqual } from "lodash";
import { sayTTS } from "src/ts/process/tts";
import { getModelShortName } from "src/ts/model/names";
export let message = ''
export let name = ''
export let largePortrait = false
@@ -18,6 +19,7 @@
export let img:string|Promise<string> = ''
export let idx = -1
export let rerollIcon = false
export let MessageGenerationInfo:MessageGenerationInfo|null = null
export let onReroll = () => {}
export let unReroll = () => {}
export let character:simpleCharacterArgument|string|null = null
@@ -199,6 +201,18 @@
{/if}
</div>
</div>
{#if MessageGenerationInfo}
<div>
<button class="text-sm p-1 text-textcolor2 border-darkborderc float-end mr-2 my-2
hover:ring-borderc hover:ring rounded-md hover:text-textcolor transition-all flex justify-center items-center"
>
<BotIcon size={20} />
<span class="ml-1">
{capitalize(getModelShortName(MessageGenerationInfo.model))}
</span>
</button>
</div>
{/if}
{#if editMode}
<AutoresizeArea bind:value={message} />
{:else}

View File

@@ -520,6 +520,7 @@
isLastMemory={$CurrentChat.lastMemory === (chat.chatId ?? 'none') && $CurrentShowMemoryLimit}
character={$CurrentSimpleCharacter}
largePortrait={$CurrentCharacter.largePortrait}
MessageGenerationInfo={chat.generationInfo}
/>
{:else}
<Chat
@@ -533,6 +534,7 @@
isLastMemory={$CurrentChat.lastMemory === (chat.chatId ?? 'none') && $CurrentShowMemoryLimit}
character={chat.saying}
largePortrait={findCharacterbyId(chat.saying).largePortrait}
MessageGenerationInfo={chat.generationInfo}
/>
{/if}
{:else}
@@ -544,6 +546,7 @@
img={getCharImage($CurrentUserIcon, 'css')}
isLastMemory={$CurrentChat.lastMemory === (chat.chatId ?? 'none') && $CurrentShowMemoryLimit}
largePortrait={$DataBase.personas[$DataBase.selectedPersona].largePortrait}
MessageGenerationInfo={chat.generationInfo}
/>
{/if}
{/each}

View File

@@ -41,4 +41,8 @@
<div class="flex items-center mt-2">
<Check bind:check={$DataBase.sideMenuRerollButton} name={language.sideMenuRerollButton}/>
</div>
<div class="flex items-center mt-2">
<Check bind:check={$DataBase.requestInfoInsideChat} name={language.requestInfoInsideChat}/>
</div>

View File

@@ -599,6 +599,7 @@ export interface Database{
modules: RisuModule[]
enabledModules: string[]
sideMenuRerollButton?:boolean
requestInfoInsideChat?:boolean
}
export interface customscript{

View File

@@ -28,7 +28,8 @@ export function messageForm(arg:Message[], loadPages:number){
data: reformatContent(m.data),
index: i,
saying: m.saying,
chatId: m.chatId ?? 'none'
chatId: m.chatId ?? 'none',
generationInfo: m.generationInfo,
})
}
return a.slice(0, loadPages)
@@ -419,4 +420,8 @@ export const toLangName = (code:string) => {
}
}
export const capitalize = (s:string) => {
return s.charAt(0).toUpperCase() + s.slice(1)
}
export const languageCodes = ["af","ak","am","an","ar","as","ay","az","be","bg","bh","bm","bn","br","bs","ca","co","cs","cy","da","de","dv","ee","el","en","eo","es","et","eu","fa","fi","fo","fr","fy","ga","gd","gl","gn","gu","ha","he","hi","hr","ht","hu","hy","ia","id","ig","is","it","iu","ja","jv","ka","kk","km","kn","ko","ku","ky","la","lb","lg","ln","lo","lt","lv","mg","mi","mk","ml","mn","mr","ms","mt","my","nb","ne","nl","nn","no","ny","oc","om","or","pa","pl","ps","pt","qu","rm","ro","ru","rw","sa","sd","si","sk","sl","sm","sn","so","sq","sr","st","su","sv","sw","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ug","uk","ur","uz","vi","wa","wo","xh","yi","yo","zh","zu"]