From d39a7b362f577b426e54a5c81d24e58600809824 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Fri, 7 Jul 2023 07:09:42 +0900 Subject: [PATCH] [feat] end lorebook param --- src/ts/process/index.ts | 11 ++++++++++- src/ts/process/lorebook.ts | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index b349a0f4..2b68bf97 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -223,11 +223,20 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n } } + const lorepmt = await loadLoreBookPrompt() unformated.lorebook.push({ role: 'system', - content: replacePlaceholders(await loadLoreBookPrompt(), currentChar.name) + content: replacePlaceholders(lorepmt.act, currentChar.name) }) + + if(lorepmt.special_act){ + unformated.postEverything.push({ + role: 'system', + content: replacePlaceholders(lorepmt.special_act, currentChar.name) + }) + } + //await tokenize currernt let currentTokens = db.maxResponse diff --git a/src/ts/process/lorebook.ts b/src/ts/process/lorebook.ts index 4d12404d..98747104 100644 --- a/src/ts/process/lorebook.ts +++ b/src/ts/process/lorebook.ts @@ -167,7 +167,20 @@ export async function loadLoreBookPrompt(){ } } - return activatiedPrompt.reverse().join('\n\n') + + let sactivated:string[] = [] + activatiedPrompt = activatiedPrompt.filter((v) => { + if(v.startsWith("@@@end")){ + sactivated.push(v.replace('@@@end','').trim()) + return false + } + return true + }) + + return { + act: activatiedPrompt.reverse().join('\n\n'), + special_act: sactivated.reverse().join('\n\n') + } }