From a70b5af0c4756e664f8debe135a746cfc594772b Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 3 Sep 2024 21:14:44 +0200 Subject: [PATCH] Prefer stickied WI for budget-limited cases - Instead of processing entries by default sorting (based on order and books (char first, etc)), sticky will now be the first to process. This will make sure that stickied entries will reach the prompt, even in budget-limited scenarios. --- public/scripts/world-info.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 8fc8a19a2..abb559d64 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -3940,8 +3940,16 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) { } console.debug(`[WI] Search done. Found ${activatedNow.size} possible entries.`); + + // Sort the entries for the probability and the budget limit checks const newEntries = [...activatedNow] - .sort((a, b) => sortedEntries.indexOf(a) - sortedEntries.indexOf(b)); + .sort((a, b) => { + const isASticky = timedEffects.isEffectActive('sticky', a) ? 1 : 0; + const isBSticky = timedEffects.isEffectActive('sticky', b) ? 1 : 0; + return isBSticky - isASticky || sortedEntries.indexOf(a) - sortedEntries.indexOf(b); + }); + + let newContent = ''; const textToScanTokens = await getTokenCountAsync(allActivatedText);