Use two @ instead of three @ for consistancy

This commit is contained in:
kwaroran
2024-01-15 12:38:31 +09:00
parent bf886325ed
commit a1c6cbdf24
2 changed files with 18 additions and 5 deletions

View File

@@ -222,10 +222,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
function formatPrompt(data:string){ function formatPrompt(data:string){
if(!data.startsWith('@@@')){ if(!data.startsWith('@@')){
data = "@@@system\n" + data data = "@@system\n" + data
} }
const parts = data.split(/@@@(user|assistant|system)\n/); const parts = data.split(/@@@?(user|assistant|system)\n/);
// Initialize empty array for the chat objects // Initialize empty array for the chat objects
const chatObjects: OpenAIChat[] = []; const chatObjects: OpenAIChat[] = [];

View File

@@ -98,12 +98,15 @@ export async function loadLoreBookPrompt(){
} }
} }
if(lore.key?.startsWith('@@@')){
lore.key = lore.key.replace('@@@','@@')
}
formatedLore.push({ formatedLore.push({
keys: lore.alwaysActive ? 'always' : (lore.key?.startsWith("@@@regex ")) ? ({type:'regex',regex:lore.key.replace('@@@regex ','')}) : keys: lore.alwaysActive ? 'always' : (lore.key?.startsWith("@@regex ")) ? ({type:'regex',regex:lore.key.replace('@@regex ','')}) :
(lore.key ?? '').replace(rmRegex, '').toLocaleLowerCase().split(',').filter((a) => { (lore.key ?? '').replace(rmRegex, '').toLocaleLowerCase().split(',').filter((a) => {
return a.length > 1 return a.length > 1
}), }),
secondKey: lore.selective ? ((lore.secondkey?.startsWith("@@@regex ")) ? ({type:'regex',regex:lore.secondkey.replace('@@@regex ','')}) : secondKey: lore.selective ? ((lore.secondkey?.startsWith("@@regex ")) ? ({type:'regex',regex:lore.secondkey.replace('@@regex ','')}) :
(lore.secondkey ?? '').replace(rmRegex, '').toLocaleLowerCase().split(',').filter((a) => { (lore.secondkey ?? '').replace(rmRegex, '').toLocaleLowerCase().split(',').filter((a) => {
return a.length > 1 return a.length > 1
})) : [], })) : [],
@@ -195,10 +198,15 @@ export async function loadLoreBookPrompt(){
let sactivated:string[] = [] let sactivated:string[] = []
activatiedPrompt = activatiedPrompt.filter((v) => { activatiedPrompt = activatiedPrompt.filter((v) => {
//deprecated three @ for special prompt
if(v.startsWith("@@@end")){ if(v.startsWith("@@@end")){
sactivated.push(v.replace('@@@end','').trim()) sactivated.push(v.replace('@@@end','').trim())
return false return false
} }
if(v.startsWith('@@end')){
sactivated.push(v.replace('@@end','').trim())
return false
}
return true return true
}) })
@@ -283,10 +291,15 @@ export async function loadLoreBookPlusPrompt(){
let sactivated:string[] = [] let sactivated:string[] = []
activatiedPrompt = activatiedPrompt.filter((v) => { activatiedPrompt = activatiedPrompt.filter((v) => {
//deprecated three @ for special prompt
if(v.startsWith("@@@end")){ if(v.startsWith("@@@end")){
sactivated.push(v.replace('@@@end','').trim()) sactivated.push(v.replace('@@@end','').trim())
return false return false
} }
if(v.startsWith('@@end')){
sactivated.push(v.replace('@@end','').trim())
return false
}
return true return true
}) })