From f80f1f9e9eb007bc493eb0b5d840b35321dc21c0 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 9 Aug 2023 01:07:22 +0900 Subject: [PATCH] [fix] posteverything not working --- src/ts/process/index.ts | 26 ++++++++++++++++++++------ src/ts/process/proompt.ts | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index dcb5b66a..c61e87d1 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -169,7 +169,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n 'personaPrompt':([] as OpenAIChat[]) } - if((!currentChar.utilityBot) && (!db.promptTemplate)){ + const promptTemplate = cloneDeep(db.promptTemplate) + + db.promptTemplate.push({ + type: 'postEverything' + }) + + if((!currentChar.utilityBot) && (!promptTemplate)){ const mainp = currentChar.systemPrompt?.replaceAll('{{original}}', db.mainPrompt) || db.mainPrompt @@ -256,8 +262,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n let currentTokens = db.maxResponse - if(db.promptTemplate){ - const template = db.promptTemplate + if(promptTemplate){ + const template = promptTemplate async function tokenizeChatArray(chats:OpenAIChat[]){ for(const chat of chats){ @@ -299,6 +305,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n await tokenizeChatArray(unformated.lorebook) break } + case 'postEverything':{ + await tokenizeChatArray(unformated.postEverything) + break + } case 'plain': case 'jailbreak':{ if((!db.jailbreakToggle) && (card.type === 'jailbreak')){ @@ -465,7 +475,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n - if(!db.promptTemplate){ + if(!promptTemplate){ unformated.lastChat.push(chats[chats.length - 1]) chats.splice(chats.length - 1, 1) } @@ -523,8 +533,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n } } - if(db.promptTemplate){ - const template = db.promptTemplate + if(promptTemplate){ + const template = promptTemplate for(const card of template){ switch(card.type){ @@ -558,6 +568,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n pushPrompts(unformated.lorebook) break } + case 'postEverything':{ + pushPrompts(unformated.postEverything) + break + } case 'plain': case 'jailbreak':{ if((!db.jailbreakToggle) && (card.type === 'jailbreak')){ diff --git a/src/ts/process/proompt.ts b/src/ts/process/proompt.ts index 0413f687..847bc3bd 100644 --- a/src/ts/process/proompt.ts +++ b/src/ts/process/proompt.ts @@ -8,7 +8,7 @@ export interface ProomptPlain { } export interface ProomptTyped { - type: 'persona'|'description'|'authornote'|'lorebook' + type: 'persona'|'description'|'authornote'|'lorebook'|'postEverything' innerFormat?: string }