Merge pull request #2766 from SillyTavern/wi-prefer-sticky-on-budget

Prefer stickied WI for budget-limited cases
This commit is contained in:
Cohee 2024-09-03 23:09:45 +03:00 committed by GitHub
commit a2710b70c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);