From d2477bba0c048fdb6fb3cb951a00e0c54d8946b8 Mon Sep 17 00:00:00 2001 From: steve green Date: Wed, 8 May 2024 22:55:33 +0800 Subject: [PATCH] also run regex on worldinfo --- public/scripts/extensions/regex/editor.html | 8 +++++++- public/scripts/extensions/regex/engine.js | 2 ++ public/scripts/world-info.js | 13 +++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/regex/editor.html b/public/scripts/extensions/regex/editor.html index 63b41b49c..00f8f367b 100644 --- a/public/scripts/extensions/regex/editor.html +++ b/public/scripts/extensions/regex/editor.html @@ -68,7 +68,7 @@
@@ -97,6 +97,12 @@ Slash Commands
+
+ +
diff --git a/public/scripts/extensions/regex/engine.js b/public/scripts/extensions/regex/engine.js index 3612de891..8441ae087 100644 --- a/public/scripts/extensions/regex/engine.js +++ b/public/scripts/extensions/regex/engine.js @@ -17,6 +17,8 @@ const regex_placement = { USER_INPUT: 1, AI_OUTPUT: 2, SLASH_COMMAND: 3, + // 4 - sendAs (legacy) + WAIN: 5, }; /** diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 4fbf7cb35..7afddf53b 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -10,6 +10,7 @@ import { power_user } from './power-user.js'; import { getTagKeyForEntity } from './tags.js'; import { resolveVariable } from './variables.js'; import { debounce_timeout } from './constants.js'; +import { getRegexedString, regex_placement } from './extensions/regex/engine.js'; export { world_info, @@ -2571,8 +2572,8 @@ async function checkWorldInfo(chat, maxContext) { } }); - const worldInfoBefore = WIBeforeEntries.length ? WIBeforeEntries.join('\n') : ''; - const worldInfoAfter = WIAfterEntries.length ? WIAfterEntries.join('\n') : ''; + var worldInfoBefore = WIBeforeEntries.length ? WIBeforeEntries.join('\n') : ''; + var worldInfoAfter = WIAfterEntries.length ? WIAfterEntries.join('\n') : ''; if (shouldWIAddPrompt) { const originalAN = context.extensionPrompts[NOTE_MODULE_NAME].value; @@ -2582,6 +2583,14 @@ async function checkWorldInfo(chat, maxContext) { buffer.cleanExternalActivations(); + { + let regexType = regex_placement.WAIN; + let options = { isPrompt: true, depth: 0 }; + + worldInfoAfter = getRegexedString(worldInfoAfter, regexType, options); + worldInfoBefore = getRegexedString(worldInfoBefore, regexType, options); + } + return { worldInfoBefore, worldInfoAfter, EMEntries, WIDepthEntries, allActivatedEntries }; }