deeplX function added
This commit is contained in:
@@ -391,6 +391,8 @@ export const languageChinese = {
|
|||||||
"translatorType": "翻译类型",
|
"translatorType": "翻译类型",
|
||||||
"deeplKey": "deepl API密钥",
|
"deeplKey": "deepl API密钥",
|
||||||
"deeplFreeKey": "deepl 免费 API密钥",
|
"deeplFreeKey": "deepl 免费 API密钥",
|
||||||
|
"deeplXUrl": "deepLX URL",
|
||||||
|
"deeplXToken": "deepLX Token",
|
||||||
"exportPersona": "导出角色",
|
"exportPersona": "导出角色",
|
||||||
"importPersona": "导入角色",
|
"importPersona": "导入角色",
|
||||||
"export": "导出",
|
"export": "导出",
|
||||||
|
|||||||
@@ -421,6 +421,8 @@ export const languageGerman = {
|
|||||||
translatorType: "Übersetzer-Typ",
|
translatorType: "Übersetzer-Typ",
|
||||||
deeplKey: "DeepL API-Schlüssel",
|
deeplKey: "DeepL API-Schlüssel",
|
||||||
deeplFreeKey: "DeepL Gratis API-Schlüssel",
|
deeplFreeKey: "DeepL Gratis API-Schlüssel",
|
||||||
|
deeplXUrl: "deepLX URL",
|
||||||
|
deeplXToken: "deepLX Token",
|
||||||
exportPersona: "Profil exportieren",
|
exportPersona: "Profil exportieren",
|
||||||
importPersona: "Profil importieren",
|
importPersona: "Profil importieren",
|
||||||
export: "Exportieren",
|
export: "Exportieren",
|
||||||
|
|||||||
@@ -456,6 +456,8 @@ export const languageEnglish = {
|
|||||||
translatorType: "Translator Type",
|
translatorType: "Translator Type",
|
||||||
deeplKey: "deepL API Key",
|
deeplKey: "deepL API Key",
|
||||||
deeplFreeKey: "deepL Free API Key",
|
deeplFreeKey: "deepL Free API Key",
|
||||||
|
deeplXUrl: "deepLX URL",
|
||||||
|
deeplXToken: "deepLX Token",
|
||||||
exportPersona: "Export Persona",
|
exportPersona: "Export Persona",
|
||||||
importPersona: "Import Persona",
|
importPersona: "Import Persona",
|
||||||
export: "Export",
|
export: "Export",
|
||||||
|
|||||||
@@ -394,6 +394,8 @@ export const languageKorean = {
|
|||||||
translatorType: "번역기 타입",
|
translatorType: "번역기 타입",
|
||||||
deeplKey: "deepL API 키",
|
deeplKey: "deepL API 키",
|
||||||
deeplFreeKey: "deepL 무료 API 키",
|
deeplFreeKey: "deepL 무료 API 키",
|
||||||
|
deeplXUrl: "deepLX URL",
|
||||||
|
deeplXToken: "deepLX Token",
|
||||||
exportPersona: "페르소나 엑스포트",
|
exportPersona: "페르소나 엑스포트",
|
||||||
importPersona: "페르소나 임포트",
|
importPersona: "페르소나 임포트",
|
||||||
export: "엑스포트",
|
export: "엑스포트",
|
||||||
|
|||||||
@@ -392,6 +392,8 @@ export const LanguageVietnamese = {
|
|||||||
"translatorType": "Loại dịch giả",
|
"translatorType": "Loại dịch giả",
|
||||||
"deeplKey": "Khóa API deepL",
|
"deeplKey": "Khóa API deepL",
|
||||||
"deeplFreeKey": "Khóa API miễn phí deepL",
|
"deeplFreeKey": "Khóa API miễn phí deepL",
|
||||||
|
"deeplXUrl": "deepLX URL",
|
||||||
|
"deeplXToken": "deepLX Token",
|
||||||
"exportPersona": "Xuất khẩu nhân vật",
|
"exportPersona": "Xuất khẩu nhân vật",
|
||||||
"importPersona": "Nhập khẩu nhân vật",
|
"importPersona": "Nhập khẩu nhân vật",
|
||||||
"export": "Xuất khẩu",
|
"export": "Xuất khẩu",
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
<OptionInput value="google" >Google</OptionInput>
|
<OptionInput value="google" >Google</OptionInput>
|
||||||
<OptionInput value="deepl" >DeepL</OptionInput>
|
<OptionInput value="deepl" >DeepL</OptionInput>
|
||||||
<OptionInput value="llm" >Ax. Model</OptionInput>
|
<OptionInput value="llm" >Ax. Model</OptionInput>
|
||||||
|
<OptionInput value="deeplX" >DeepL X</OptionInput>
|
||||||
</SelectInput>
|
</SelectInput>
|
||||||
|
|
||||||
{#if $DataBase.translatorType === 'deepl'}
|
{#if $DataBase.translatorType === 'deepl'}
|
||||||
@@ -72,6 +73,14 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if $DataBase.translatorType === 'deeplX'}
|
||||||
|
<span class="text-textcolor mt-4">{language.deeplXUrl}</span>
|
||||||
|
<TextInput bind:value={$DataBase.deeplXOptions.url} />
|
||||||
|
|
||||||
|
<span class="text-textcolor mt-4">{language.deeplXToken}</span>
|
||||||
|
<TextInput bind:value={$DataBase.deeplXOptions.token} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $DataBase.translatorType === 'llm'}
|
{#if $DataBase.translatorType === 'llm'}
|
||||||
<span class="text-textcolor mt-4">{language.translationPrompt}</span>
|
<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."}/>
|
<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."}/>
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ export async function sayTTS(character:character,text:string) {
|
|||||||
const audioContext = new AudioContext();
|
const audioContext = new AudioContext();
|
||||||
const da = await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${character.ttsSpeech}`, {
|
const da = await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${character.ttsSpeech}`, {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
text: text
|
text: text,
|
||||||
|
model_id: "eleven_multilingual_v2"
|
||||||
}),
|
}),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -332,6 +332,10 @@ export function setDatabase(data:Database){
|
|||||||
key:'',
|
key:'',
|
||||||
freeApi: false
|
freeApi: false
|
||||||
}
|
}
|
||||||
|
data.deeplXOptions ??= {
|
||||||
|
url:'',
|
||||||
|
token:''
|
||||||
|
}
|
||||||
data.NAIadventure ??= false
|
data.NAIadventure ??= false
|
||||||
data.NAIappendName ??= true
|
data.NAIappendName ??= true
|
||||||
data.NAIsettings.cfg_scale ??= 1
|
data.NAIsettings.cfg_scale ??= 1
|
||||||
@@ -555,13 +559,17 @@ export interface Database{
|
|||||||
mancerHeader:string
|
mancerHeader:string
|
||||||
emotionProcesser:'submodel'|'embedding',
|
emotionProcesser:'submodel'|'embedding',
|
||||||
showMenuChatList?:boolean,
|
showMenuChatList?:boolean,
|
||||||
translatorType:'google'|'deepl'|'none'|'llm',
|
translatorType:'google'|'deepl'|'none'|'llm'|'deeplX',
|
||||||
NAIadventure?:boolean,
|
NAIadventure?:boolean,
|
||||||
NAIappendName?:boolean,
|
NAIappendName?:boolean,
|
||||||
deeplOptions:{
|
deeplOptions:{
|
||||||
key:string,
|
key:string,
|
||||||
freeApi:boolean
|
freeApi:boolean
|
||||||
}
|
}
|
||||||
|
deeplXOptions:{
|
||||||
|
url:string,
|
||||||
|
token:string
|
||||||
|
}
|
||||||
localStopStrings?:string[]
|
localStopStrings?:string[]
|
||||||
autofillRequestUrl:boolean
|
autofillRequestUrl:boolean
|
||||||
customProxyRequestModel:string
|
customProxyRequestModel:string
|
||||||
|
|||||||
@@ -127,6 +127,29 @@ async function translateMain(text:string, arg:{from:string, to:string, host:stri
|
|||||||
return f.data.translations[0].text
|
return f.data.translations[0].text
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(db.translatorType === 'deeplX'){
|
||||||
|
const body = {
|
||||||
|
text: [text],
|
||||||
|
target_lang: arg.to.toLocaleUpperCase(),
|
||||||
|
source_lang: arg.from.toLocaleUpperCase()
|
||||||
|
}
|
||||||
|
let url = db.deeplXOptions.url
|
||||||
|
const f = await globalFetch(url, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization" : "Bearer " + db.deeplXOptions.token
|
||||||
|
},
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
|
||||||
|
if(!f.ok){
|
||||||
|
return 'ERR::DeepLX API Error' + (await f.data)
|
||||||
|
}
|
||||||
|
return f.data.translations[0].text
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const url = `https://${arg.host}/translate_a/single?client=gtx&dt=t&sl=${arg.from}&tl=${arg.to}&q=` + encodeURIComponent(text)
|
const url = `https://${arg.host}/translate_a/single?client=gtx&dt=t&sl=${arg.from}&tl=${arg.to}&q=` + encodeURIComponent(text)
|
||||||
|
|
||||||
|
|
||||||
@@ -171,7 +194,7 @@ async function jaTrans(text:string) {
|
|||||||
|
|
||||||
export function isExpTranslator(){
|
export function isExpTranslator(){
|
||||||
const db = get(DataBase)
|
const db = get(DataBase)
|
||||||
return db.translatorType === 'llm' || db.translatorType === 'deepl'
|
return db.translatorType === 'llm' || db.translatorType === 'deepl' || db.translatorType === 'deeplX'
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function translateHTML(html: string, reverse:boolean, charArg:simpleCharacterArgument|string = ''): Promise<string> {
|
export async function translateHTML(html: string, reverse:boolean, charArg:simpleCharacterArgument|string = ''): Promise<string> {
|
||||||
|
|||||||
Reference in New Issue
Block a user