[feat] better nai support
This commit is contained in:
@@ -430,4 +430,6 @@ export const languageEnglish = {
|
||||
supporterThanksDesc: "Thank you for your support!",
|
||||
donatorPatreonDesc:"For default, it will not be shown in the list for privacy. if you want to show your nickname, go to RisuAI's patreon page and press the link button.",
|
||||
useNamePrefix: "Use Name Prefix",
|
||||
textAdventureNAI: "Run as Text Adventure",
|
||||
appendNameNAI: "Append Name on NAI",
|
||||
}
|
||||
@@ -208,11 +208,13 @@
|
||||
<span class="text-textcolor">NovelAI Bearer Token</span>
|
||||
<TextInput marginBottom={true} bind:value={$DataBase.novelai.token}/>
|
||||
|
||||
<!-- {#if !($DataBase.novelai.token)}
|
||||
<div class="mb-2">
|
||||
<Button on:click={novelLogin} size="sm">Login to NovelAI</Button>
|
||||
</div>
|
||||
{/if} -->
|
||||
<div class="flex items-center mt-2 mb-4">
|
||||
<Check bind:check={$DataBase.NAIadventure} name={language.textAdventureNAI}/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-2 mb-4">
|
||||
<Check bind:check={$DataBase.NAIappendName} name={language.appendNameNAI}/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if $DataBase.aiModel === "kobold" || $DataBase.subModel === "kobold"}
|
||||
|
||||
@@ -13,8 +13,6 @@ export function stringlizeNAIChat(formated:OpenAIChat[], char:string, continued:
|
||||
let starter = db.NAIsettings.starter.replaceAll("\\n","\n") || '***\n[conversation: start]'
|
||||
let resultString:string[] = []
|
||||
|
||||
console.log(formated)
|
||||
|
||||
for(const form of formated){
|
||||
if(form.role === 'system'){
|
||||
if(form.memo === 'NewChatExample' || form.memo === 'NewChat' || form.content === "[Start a new chat]"){
|
||||
@@ -25,10 +23,23 @@ export function stringlizeNAIChat(formated:OpenAIChat[], char:string, continued:
|
||||
}
|
||||
}
|
||||
else if(form.name || form.role === 'assistant'){
|
||||
resultString.push((form.name ?? char) + ": " + form.content)
|
||||
if(db.NAIappendName){
|
||||
resultString.push(form.content)
|
||||
}
|
||||
else{
|
||||
resultString.push((form.name ?? char) + ": " + form.content)
|
||||
}
|
||||
}
|
||||
else if(form.role === 'user'){
|
||||
resultString.push(db.username + ": " + form.content)
|
||||
let res = ''
|
||||
if(db.NAIadventure){
|
||||
res += '> '
|
||||
}
|
||||
if(db.NAIappendName){
|
||||
res += db.username + ": "
|
||||
}
|
||||
res += form.content
|
||||
resultString.push(res)
|
||||
}
|
||||
else{
|
||||
resultString.push(form.content)
|
||||
@@ -38,7 +49,7 @@ export function stringlizeNAIChat(formated:OpenAIChat[], char:string, continued:
|
||||
let res = resultString.join(seperator)
|
||||
|
||||
if(!continued){
|
||||
res += `\n\n${char}:`
|
||||
res += `${seperator}${char}:`
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -381,6 +381,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
})
|
||||
}
|
||||
|
||||
let prefix = 'vanilla'
|
||||
|
||||
if(db.NAIadventure){
|
||||
prefix = 'theme_textadventure'
|
||||
}
|
||||
|
||||
const gen = db.NAIsettings
|
||||
const payload = {
|
||||
temperature:temperature,
|
||||
@@ -399,16 +405,18 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
use_cache: false,
|
||||
use_string: true,
|
||||
return_full_text: false,
|
||||
prefix: 'vanilla',
|
||||
prefix: prefix,
|
||||
order: [2, 3, 0, 4, 1],
|
||||
typical_p: gen.typicalp,
|
||||
repetition_penalty_whitelist:[49256,49264,49231,49230,49287,85,49255,49399,49262,336,333,432,363,468,492,745,401,426,623,794,1096,2919,2072,7379,1259,2110,620,526,487,16562,603,805,761,2681,942,8917,653,3513,506,5301,562,5010,614,10942,539,2976,462,5189,567,2032,123,124,125,126,127,128,129,130,131,132,588,803,1040,49209,4,5,6,7,8,9,10,11,12],
|
||||
stop_sequences: [[49287]],
|
||||
stop_sequences: [[49287], [49405]],
|
||||
bad_words_ids: NovelAIBadWordIds,
|
||||
logit_bias_exp: logit_bias_exp
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const body = {
|
||||
"input": proompt,
|
||||
|
||||
@@ -472,6 +472,8 @@ export interface Database{
|
||||
emotionProcesser:'submodel'|'embedding',
|
||||
showMenuChatList?:boolean,
|
||||
translatorType:'google'|'deepl'|'none',
|
||||
NAIadventure?:boolean,
|
||||
NAIappendName?:boolean,
|
||||
deeplOptions:{
|
||||
key:string,
|
||||
freeApi:boolean
|
||||
|
||||
Reference in New Issue
Block a user