[fix] ooba formating

This commit is contained in:
kwaroran
2023-08-24 17:57:25 +09:00
parent d8a2df7c91
commit 327bc93456

View File

@@ -38,9 +38,11 @@ export function stringlizeChatOba(formated:OpenAIChat[], characterName:string, s
const db = get(DataBase) const db = get(DataBase)
let resultString:string[] = [] let resultString:string[] = []
let { header, systemPrefix, userPrefix, assistantPrefix, seperator } = db.ooba.formating; let { header, systemPrefix, userPrefix, assistantPrefix, seperator } = db.ooba.formating;
if(!seperator){ header = header ?? ""
seperator = "\n\n" systemPrefix = systemPrefix ?? ""
} userPrefix = userPrefix ?? ""
assistantPrefix = assistantPrefix ?? ""
seperator = seperator ?? "\n\n"
if(header) { if(header) {
resultString.push(header) resultString.push(header)
@@ -50,25 +52,39 @@ export function stringlizeChatOba(formated:OpenAIChat[], characterName:string, s
continue continue
} }
let prefix = "" let prefix = ""
let name = "" let name = form.name
if(form.role === 'user'){ if(form.role === 'user'){
prefix = appendWhitespace(suggesting ? assistantPrefix : userPrefix, seperator) prefix = appendWhitespace(suggesting ? assistantPrefix : userPrefix, seperator)
name = `${db.username}: ` name ??= `${db.username}: `
} }
else if(form.role === 'assistant'){ else if(form.role === 'assistant'){
prefix = appendWhitespace(suggesting ? userPrefix : assistantPrefix, seperator) prefix = appendWhitespace(suggesting ? userPrefix : assistantPrefix, seperator)
name = `${characterName}: ` name ??= `${characterName}: `
} }
else if(form.role === 'system'){ else if(form.role === 'system'){
prefix = appendWhitespace(systemPrefix, seperator) prefix = appendWhitespace(systemPrefix, seperator)
} }
resultString.push(prefix + name + form.content) if(db.ooba.formating.useName){
resultString.push(prefix + name + form.content)
}
else{
resultString.push(prefix + form.content)
}
} }
if(!continued){ if(!continued){
if (suggesting){ if(db.ooba.formating.useName){
resultString.push(appendWhitespace(assistantPrefix, seperator) + `${db.username}:\n` + db.autoSuggestPrefix) if (suggesting){
} else { resultString.push(appendWhitespace(assistantPrefix, seperator) + `${db.username}:\n` + db.autoSuggestPrefix)
resultString.push(assistantPrefix + `${characterName}:`) } else {
resultString.push(assistantPrefix + `${characterName}:`)
}
}
else{
if (suggesting){
resultString.push(appendWhitespace(assistantPrefix, seperator) + `\n` + db.autoSuggestPrefix)
} else {
resultString.push(assistantPrefix)
}
} }
} }
return resultString.join(seperator) return resultString.join(seperator)