Merge branch 'staging' into wi-regex-keys

This commit is contained in:
Wolfsblvt 2024-05-09 22:54:27 +02:00
commit a2625ecec6
2 changed files with 14 additions and 14 deletions

View File

@ -2097,7 +2097,6 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll
const newMessage = $(`#chat [mesid="${newMessageId}"]`);
const isSmallSys = mes?.extra?.isSmallSys;
newMessage.data('isSystem', isSystem);
if (isSmallSys === true) {
newMessage.addClass('smallSysMes');
@ -9351,14 +9350,9 @@ jQuery(async function () {
else {
$(document).on('pointerup', '.mes_copy', function () {
if (this_chid !== undefined || selected_group) {
const message = $(this).closest('.mes');
if (message.data('isSystem')) {
return;
}
try {
var edit_mes_id = $(this).closest('.mes').attr('mesid');
var text = chat[edit_mes_id]['mes'];
const messageId = $(this).closest('.mes').attr('mesid');
const text = chat[messageId]['mes'];
navigator.clipboard.writeText(text);
toastr.info('Copied!', '', { timeOut: 2000 });
} catch (err) {
@ -9617,8 +9611,8 @@ jQuery(async function () {
}
hideSwipeButtons();
let oldScroll = $('#chat')[0].scrollTop;
const clone = JSON.parse(JSON.stringify(chat[this_edit_mes_id])); // quick and dirty clone
const oldScroll = chatElement[0].scrollTop;
const clone = structuredClone(chat[this_edit_mes_id]);
clone.send_date = Date.now();
clone.mes = $(this).closest('.mes').find('.edit_textarea').val();
@ -9631,7 +9625,7 @@ jQuery(async function () {
updateViewMessageIds();
await saveChatConditional();
$('#chat')[0].scrollTop = oldScroll;
chatElement[0].scrollTop = oldScroll;
showSwipeButtons();
});

View File

@ -2581,7 +2581,6 @@ async function checkWorldInfo(chat, maxContext) {
}
if (entry.constant || buffer.isExternallyActivated(entry)) {
entry.content = substituteParams(entry.content);
activatedNow.add(entry);
continue;
}
@ -2674,7 +2673,9 @@ async function checkWorldInfo(chat, maxContext) {
continue;
} else { console.debug(`uid:${entry.uid} passed probability check, inserting to prompt`); }
newContent += `${substituteParams(entry.content)}\n`;
// Substitute macros inline, for both this checking and also future processing
entry.content = substituteParams(entry.content);
newContent += `${entry.content}\n`;
if ((textToScanTokens + (await getTokenCountAsync(newContent))) >= budget) {
console.debug('WI budget reached, stopping');
@ -2707,7 +2708,7 @@ async function checkWorldInfo(chat, maxContext) {
const text = newEntries
.filter(x => !failedProbabilityChecks.has(x))
.filter(x => !x.preventRecursion)
.map(x => substituteParams(x.content)).join('\n');
.map(x => x.content).join('\n');
buffer.addRecurse(text);
allActivatedText = (text + '\n' + allActivatedText);
}
@ -2742,6 +2743,11 @@ async function checkWorldInfo(chat, maxContext) {
const regexDepth = entry.position === world_info_position.atDepth ? (entry.depth ?? DEFAULT_DEPTH) : null;
const content = getRegexedString(entry.content, regex_placement.WORLD_INFO, { depth: regexDepth, isMarkdown: false, isPrompt: true });
if (!content) {
console.debug('Skipping adding WI entry to prompt due to empty content:', entry);
return;
}
switch (entry.position) {
case world_info_position.before:
WIBeforeEntries.unshift(substituteParams(content));