[fix] oobabooga prompt template and autosuggest (#226)
# PR Checklist - [x] Did you check if it works normally in all models? *ignore this when it dosen't uses models* - [x] Did you check if it works normally in all of web, local and node hosted versions? if it dosen't, did you blocked it in those versions? - [x] Did you added a type def? # Description The changes in #225 didn't seem to be enough, so I made an additional fix.
This commit is contained in:
@@ -399,7 +399,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
let blockingUrl = db.textgenWebUIBlockingURL.replace(/\/api.*/, "/api/v1/generate")
|
||||
let bodyTemplate:any
|
||||
const suggesting = model === "submodel"
|
||||
const proompt = stringlizeChatOba(formated, suggesting)
|
||||
const proompt = stringlizeChatOba(formated, currentChar.name, suggesting)
|
||||
const stopStrings = getStopStrings(suggesting)
|
||||
console.log(proompt)
|
||||
console.log(stopStrings)
|
||||
|
||||
@@ -29,7 +29,7 @@ function appendWhitespace(prefix:string, seperator:string=" ") {
|
||||
}
|
||||
return prefix
|
||||
}
|
||||
export function stringlizeChatOba(formated:OpenAIChat[], suggesting:boolean=false){
|
||||
export function stringlizeChatOba(formated:OpenAIChat[], characterName:string='', suggesting:boolean=false){
|
||||
const db = get(DataBase)
|
||||
let resultString:string[] = []
|
||||
let { header, systemPrefix, userPrefix, assistantPrefix, seperator } = db.ooba.formating;
|
||||
@@ -45,21 +45,24 @@ export function stringlizeChatOba(formated:OpenAIChat[], suggesting:boolean=fals
|
||||
continue
|
||||
}
|
||||
let prefix = ""
|
||||
let name = ""
|
||||
if(form.role === 'user'){
|
||||
prefix = appendWhitespace(userPrefix, seperator)
|
||||
prefix = appendWhitespace(suggesting ? assistantPrefix : userPrefix, seperator)
|
||||
name = `${db.username}: `
|
||||
}
|
||||
else if(form.role === 'assistant'){
|
||||
prefix = appendWhitespace(assistantPrefix, seperator)
|
||||
prefix = appendWhitespace(suggesting ? userPrefix : assistantPrefix, seperator)
|
||||
name = `${characterName}: `
|
||||
}
|
||||
else if(form.role === 'system'){
|
||||
prefix = appendWhitespace(systemPrefix, seperator)
|
||||
}
|
||||
resultString.push(prefix + form.content)
|
||||
resultString.push(prefix + name + form.content)
|
||||
}
|
||||
if (suggesting){
|
||||
resultString.push(appendWhitespace(assistantPrefix, seperator) + "\n" + db.autoSuggestPrefix)
|
||||
resultString.push(appendWhitespace(assistantPrefix, seperator) + `${db.username}:\n` + db.autoSuggestPrefix)
|
||||
} else {
|
||||
resultString.push(assistantPrefix)
|
||||
resultString.push(assistantPrefix + `${characterName}:`)
|
||||
}
|
||||
return resultString.join(seperator)
|
||||
}
|
||||
@@ -81,6 +84,9 @@ export function getStopStrings(suggesting:boolean=false){
|
||||
"<|end",
|
||||
"<|im_end",
|
||||
userPrefix,
|
||||
"\nYou ",
|
||||
`*${username}'`,
|
||||
`*${username} `,
|
||||
`\n${username} `,
|
||||
`${username}:`,
|
||||
]
|
||||
@@ -90,6 +96,10 @@ export function getStopStrings(suggesting:boolean=false){
|
||||
if(suggesting){
|
||||
stopStrings.push("\n\n")
|
||||
}
|
||||
if(!suggesting){
|
||||
stopStrings.push("*You ")
|
||||
stopStrings.push(" You ")
|
||||
}
|
||||
for (const user of userStrings){
|
||||
for (const u of [
|
||||
user.toLowerCase(),
|
||||
|
||||
@@ -49,8 +49,9 @@ export async function setRecommended(model: string, ask:'ask'|'force') {
|
||||
pr.mainPrompt = pr.bias = pr.globalNote = undefined
|
||||
pr.jailbreak = ""
|
||||
if(!db.autoSuggestPrompt || db.autoSuggestPrompt === defaultAutoSuggestPrompt){
|
||||
pr.autoSuggestPrompt = defaultAutoSuggestPromptOoba;
|
||||
pr.autoSuggestPrefix = defaultAutoSuggestPrefixOoba;
|
||||
pr.autoSuggestPrompt = defaultAutoSuggestPromptOoba
|
||||
pr.autoSuggestPrefix = defaultAutoSuggestPrefixOoba
|
||||
pr.autoSuggestClean = true
|
||||
}
|
||||
switch(sel){
|
||||
case 0:{ //Vicuna, WizardLM, Airoboros
|
||||
|
||||
Reference in New Issue
Block a user