fixRequest things that weren't covered in the last pull request.
Signed-off-by: hashcoko <hashcoko@gmail.com>
This commit is contained in:
@@ -12,11 +12,6 @@
|
||||
import VisualNovelMain from "../VisualNovel/VisualNovelMain.svelte";
|
||||
let openChatList = false
|
||||
|
||||
|
||||
if ($DataBase.translatorType === 'submodel'){
|
||||
$DataBase.useStreaming = false
|
||||
}
|
||||
|
||||
const wallPaper = `background: url(${defaultWallpaper})`
|
||||
const externalStyles =
|
||||
("background: " + ($DataBase.textScreenColor ? ($DataBase.textScreenColor + '80') : "rgba(0,0,0,0.8)") + ';\n')
|
||||
|
||||
@@ -69,13 +69,6 @@
|
||||
<Check bind:check={$DataBase.deeplOptions.freeApi} name={language.deeplFreeKey}/>
|
||||
</div>
|
||||
|
||||
{:else if $DataBase.translatorType === 'submodel'}
|
||||
<span class="text-textcolor mt-4">Translate Prompt</span>
|
||||
<TextInput bind:value={$DataBase.translatorprompt} placeholder="If empty, use the default prompt."/>
|
||||
<span class="text-draculared text-xs mb-2">Response streaming is disabled when using submodels.</span>
|
||||
<span class="text-draculared text-xs mb-2">Translation sends a lot of requests at once, so don't use it at reverse proxy.</span>
|
||||
{/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."}/>
|
||||
|
||||
@@ -309,9 +309,6 @@ export function setDatabase(data:Database){
|
||||
if(!data.formatingOrder.includes('personaPrompt')){
|
||||
data.formatingOrder.splice(data.formatingOrder.indexOf('main'),0,'personaPrompt')
|
||||
}
|
||||
if(checkNullish(data.translatorprompt)){
|
||||
data.translatorprompt = ""
|
||||
}
|
||||
data.selectedPersona ??= 0
|
||||
data.personaPrompt ??= ''
|
||||
data.personas ??= [{
|
||||
@@ -530,7 +527,6 @@ export interface Database{
|
||||
key:string,
|
||||
freeApi:boolean
|
||||
}
|
||||
translatorprompt:string
|
||||
localStopStrings?:string[]
|
||||
autofillRequestUrl:boolean
|
||||
customProxyRequestModel:string
|
||||
|
||||
@@ -125,40 +125,6 @@ async function translateMain(text:string, arg:{from:string, to:string, host:stri
|
||||
return f.data.translations[0].text
|
||||
|
||||
}
|
||||
|
||||
if(db.translatorType === 'submodel'){
|
||||
|
||||
const defaulttranslateprompt = `You need to translate the entered sentence from ${arg.from.toLocaleUpperCase()} to ${arg.to.toLocaleUpperCase()}. You must not write any words other than the translated sentence.`
|
||||
|
||||
const translateprompt = (db.translatorprompt === '')? defaulttranslateprompt : db.translatorprompt
|
||||
|
||||
const promptbody:OpenAIChat[] = [
|
||||
{
|
||||
role:'system',
|
||||
content: translateprompt
|
||||
},
|
||||
{
|
||||
role: 'user',
|
||||
content: text
|
||||
},
|
||||
]
|
||||
const rq = await requestChatData({
|
||||
formated: promptbody,
|
||||
temperature: 0.2,
|
||||
maxTokens: 500,
|
||||
bias: {}
|
||||
}, 'submodel')
|
||||
|
||||
if(rq.type === 'fail' || rq.type === 'streaming' || rq.type === 'multiline'){
|
||||
alertError(`${rq.result}`)
|
||||
return false
|
||||
}
|
||||
|
||||
const r = rq.result
|
||||
console.log(r)
|
||||
|
||||
return r
|
||||
}
|
||||
const url = `https://${arg.host}/translate_a/single?client=gtx&dt=t&sl=${arg.from}&tl=${arg.to}&q=` + encodeURIComponent(text)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user