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