mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Clone WI entries before returning them to evaluator
This commit is contained in:
@@ -1501,7 +1501,7 @@ function substituteParams(content, _name1, _name2, _original) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function randomReplace(input, emptyListPlaceholder = '') {
|
function randomReplace(input, emptyListPlaceholder = '') {
|
||||||
const randomPattern = /{{random:([^}]+)}}/g;
|
const randomPattern = /{{random:([^}]+)}}/gi;
|
||||||
|
|
||||||
return input.replace(randomPattern, (match, listString) => {
|
return input.replace(randomPattern, (match, listString) => {
|
||||||
const list = listString.split(',').map(item => item.trim()).filter(item => item.length > 0);
|
const list = listString.split(',').map(item => item.trim()).filter(item => item.length > 0);
|
||||||
|
@@ -676,3 +676,7 @@ export function uuidv4() {
|
|||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function deepClone(obj) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type } from "../script.js";
|
import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type } from "../script.js";
|
||||||
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, delay, getCharaFilename } from "./utils.js";
|
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, delay, getCharaFilename, deepClone } from "./utils.js";
|
||||||
import { getContext } from "./extensions.js";
|
import { getContext } from "./extensions.js";
|
||||||
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./extensions/floating-prompt/index.js";
|
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./extensions/floating-prompt/index.js";
|
||||||
import { registerSlashCommand } from "./slash-commands.js";
|
import { registerSlashCommand } from "./slash-commands.js";
|
||||||
@@ -898,7 +898,8 @@ async function getSortedEntries() {
|
|||||||
|
|
||||||
console.debug(`Sorted ${entries.length} world lore entries using strategy ${world_info_character_strategy}`);
|
console.debug(`Sorted ${entries.length} world lore entries using strategy ${world_info_character_strategy}`);
|
||||||
|
|
||||||
return entries;
|
// Need to deep clone the entries to avoid modifying the cached data
|
||||||
|
return deepClone(entries);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
Reference in New Issue
Block a user