From a1c6cbdf244131fb8bcc234ef260de9101ad479f Mon Sep 17 00:00:00 2001 From: kwaroran Date: Mon, 15 Jan 2024 12:38:31 +0900 Subject: [PATCH] Use two @ instead of three @ for consistancy --- src/ts/process/index.ts | 6 +++--- src/ts/process/lorebook.ts | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index 1a2bac43..f9ee8a79 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -222,10 +222,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n function formatPrompt(data:string){ - if(!data.startsWith('@@@')){ - data = "@@@system\n" + data + if(!data.startsWith('@@')){ + 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 const chatObjects: OpenAIChat[] = []; diff --git a/src/ts/process/lorebook.ts b/src/ts/process/lorebook.ts index 38bff940..c1dd272e 100644 --- a/src/ts/process/lorebook.ts +++ b/src/ts/process/lorebook.ts @@ -98,12 +98,15 @@ export async function loadLoreBookPrompt(){ } } + if(lore.key?.startsWith('@@@')){ + lore.key = lore.key.replace('@@@','@@') + } 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) => { 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) => { return a.length > 1 })) : [], @@ -195,10 +198,15 @@ export async function loadLoreBookPrompt(){ let sactivated:string[] = [] activatiedPrompt = activatiedPrompt.filter((v) => { + //deprecated three @ for special prompt if(v.startsWith("@@@end")){ sactivated.push(v.replace('@@@end','').trim()) return false } + if(v.startsWith('@@end')){ + sactivated.push(v.replace('@@end','').trim()) + return false + } return true }) @@ -283,10 +291,15 @@ export async function loadLoreBookPlusPrompt(){ let sactivated:string[] = [] activatiedPrompt = activatiedPrompt.filter((v) => { + //deprecated three @ for special prompt if(v.startsWith("@@@end")){ sactivated.push(v.replace('@@@end','').trim()) return false } + if(v.startsWith('@@end')){ + sactivated.push(v.replace('@@end','').trim()) + return false + } return true })