From c169cd4e96a99ae3ffc9870e7867a9dc5dcf372b Mon Sep 17 00:00:00 2001 From: kwaroran Date: Thu, 30 May 2024 12:23:35 +0900 Subject: [PATCH] feat: add pt_ positions --- src/ts/process/index.ts | 29 ++++++++++++++++++++--------- src/ts/process/lorebook.ts | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index 371e2b45..ea679c51 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -418,6 +418,18 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n //for unexpected error currentTokens += 50 + const positionRegex = /{{position::(.+?)}}/g + const positionParser = (text:string) => { + return text.replace(positionRegex, (match, p1) => { + const MatchingLorebooks = lorepmt.actives.filter(v => { + return v.pos === ('pt_' + p1) + }) + + return MatchingLorebooks.map(v => { + return v.prompt + }).join('\n') + }) + } if(promptTemplate){ const template = promptTemplate @@ -429,14 +441,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n } } - for(const card of template){ switch(card.type){ case 'persona':{ let pmt = structuredClone(unformated.personaPrompt) if(card.innerFormat && pmt.length > 0){ for(let i=0;i 0){ for(let i=0;i 0){ for(let i=0;i 0){ for(let i=0;i 0){ for(let i=0;i 0){ for(let i=0;i