[feat] add llm translation
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
import { doingChat, sendChat } from "../../ts/process/index";
|
||||
import { findCharacterbyId, messageForm, sleep } from "../../ts/util";
|
||||
import { language } from "../../lang";
|
||||
import { translate } from "../../ts/translator/translator";
|
||||
import { isExpTranslator, translate } from "../../ts/translator/translator";
|
||||
import { alertError, alertNormal, alertWait } from "../../ts/alert";
|
||||
import sendSound from '../../etc/send.mp3'
|
||||
import {cloneDeep} from 'lodash'
|
||||
@@ -251,7 +251,33 @@
|
||||
|
||||
$: updateInputSizeAll()
|
||||
|
||||
function updateInputTransateMessage(reverse: boolean) {
|
||||
async function updateInputTransateMessage(reverse: boolean) {
|
||||
if(isExpTranslator()){
|
||||
if(!reverse){
|
||||
messageInputTranslate = ''
|
||||
return
|
||||
}
|
||||
if(messageInputTranslate === '') {
|
||||
messageInput = ''
|
||||
return
|
||||
}
|
||||
const lastMessageInputTranslate = messageInputTranslate
|
||||
await sleep(1500)
|
||||
if(lastMessageInputTranslate === messageInputTranslate){
|
||||
console.log(lastMessageInputTranslate === messageInputTranslate)
|
||||
console.log(lastMessageInputTranslate, messageInputTranslate)
|
||||
translate(reverse ? messageInputTranslate : messageInput, reverse).then((translatedMessage) => {
|
||||
if(translatedMessage){
|
||||
if(reverse)
|
||||
messageInput = translatedMessage
|
||||
else
|
||||
messageInputTranslate = translatedMessage
|
||||
}
|
||||
})
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
if(reverse && messageInputTranslate === '') {
|
||||
messageInput = ''
|
||||
return
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { downloadFile } from "src/ts/storage/globalApi";
|
||||
import { languageEnglish } from "src/lang/en";
|
||||
import TextInput from "src/lib/UI/GUI/TextInput.svelte";
|
||||
import TextAreaInput from "src/lib/UI/GUI/TextAreaInput.svelte";
|
||||
let langChanged = false
|
||||
</script>
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.language}</h2>
|
||||
@@ -56,6 +57,7 @@
|
||||
<SelectInput className="mt-2 mb-4" bind:value={$DataBase.translatorType}>
|
||||
<OptionInput value="google" >Google</OptionInput>
|
||||
<OptionInput value="deepl" >DeepL</OptionInput>
|
||||
<OptionInput value="llm" >Ax. Model</OptionInput>
|
||||
</SelectInput>
|
||||
|
||||
{#if $DataBase.translatorType === 'deepl'}
|
||||
@@ -69,6 +71,11 @@
|
||||
|
||||
{/if}
|
||||
|
||||
{#if $DataBase.translatorType === 'llm'}
|
||||
<span class="text-textcolor mt-4">{language.translationPrompt}</span>
|
||||
<TextAreaInput bind:value={$DataBase.translatorPrompt} placeholder={"You are a translator. translate the following html or text into {{slot}}. do not output anything other than the translation."}/>
|
||||
{/if}
|
||||
|
||||
|
||||
<div class="flex items-center mt-2">
|
||||
<Check bind:check={$DataBase.autoTranslate} name={language.autoTranslation}/>
|
||||
|
||||
Reference in New Issue
Block a user