From ff1399d1ba62a752dd82fc0ffca4328af32a6657 Mon Sep 17 00:00:00 2001 From: steve green Date: Thu, 9 May 2024 08:28:33 +0800 Subject: [PATCH] remove empty lines from WIs --- public/scripts/world-info.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 77ccbf8bd..45f99c98a 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -2575,12 +2575,15 @@ async function checkWorldInfo(chat, maxContext) { } }); - const worldInfoBefore = WIBeforeEntries.length ? WIBeforeEntries.join('\n') : ''; - const worldInfoAfter = WIAfterEntries.length ? WIAfterEntries.join('\n') : ''; + //remove entries that are empty + let notempty = (entry) => entry !== '' + + const worldInfoBefore = WIBeforeEntries.filter(notempty).join('\n'); + const worldInfoAfter = WIAfterEntries.filter(notempty).join('\n'); if (shouldWIAddPrompt) { const originalAN = context.extensionPrompts[NOTE_MODULE_NAME].value; - const ANWithWI = `${ANTopEntries.join('\n')}\n${originalAN}\n${ANBottomEntries.join('\n')}`; + const ANWithWI = `${ANTopEntries.filter(notempty).join('\n')}\n${originalAN}\n${ANBottomEntries.filter(notempty).join('\n')}`; context.setExtensionPrompt(NOTE_MODULE_NAME, ANWithWI, chat_metadata[metadata_keys.position], chat_metadata[metadata_keys.depth], extension_settings.note.allowWIScan, chat_metadata[metadata_keys.role]); }