[feat] better nai support

This commit is contained in:
kwaroran
2023-08-28 00:32:57 +09:00
parent 269673c671
commit f1fce49b89
5 changed files with 37 additions and 12 deletions

View File

@@ -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
}