Better WI type readability, fixed clone and type opeators.

8dc66bd21b1697ddddc7709ac733b6c8a81e2081

bmen25124 <bmen25124@gmail.com>

3 files changed, +21 -7Showing whitespace changes
public/scripts/openai.js+1 -1
@@ -710,7 +710,7 @@ export function formatWorldInfo(value, { wiFormat = null } = {}) {
710 return '';710 return '';
711 }711 }
712712
713 const format = wiFormat || oai_settings.wi_format;713 const format = wiFormat ?? oai_settings.wi_format;
714714
715 if (!format.trim()) {715 if (!format.trim()) {
716 return value;716 return value;
public/scripts/power-user.js+1 -1
@@ -1992,7 +1992,7 @@ export function fuzzySearchGroups(searchValue, fuzzySearchCaches = null) {
1992 */1992 */
1993export function renderStoryString(params, { customStoryString = null, customInstructSettings = null } = {}) {1993export function renderStoryString(params, { customStoryString = null, customInstructSettings = null } = {}) {
1994 try {1994 try {
1995 const storyString = customStoryString ?? power_user.context.story_string;1995 const storyString = structuredClone(customStoryString ?? power_user.context.story_string);
1996 const instructSettings = customInstructSettings ?? power_user.instruct;1996 const instructSettings = customInstructSettings ?? power_user.instruct;
19971997
1998 // Validate and log possible warnings/errors1998 // Validate and log possible warnings/errors
public/scripts/world-info.js+19 -5
@@ -753,10 +753,17 @@ export const worldInfoCache = new StructuredCloneMap({ cloneOnGet: true, cloneOn
753753
754/**754/**
755 * Gets the world info based on chat messages.755 * Gets the world info based on chat messages.
756 * @param {string[]} chat The chat messages to scan, in reverse order.756 * @param {string[]} chat - The chat messages to scan, in reverse order.
757 * @param {number} maxContext The maximum context size of the generation.757 * @param {number} maxContext - The maximum context size of the generation.
758 * @param {boolean} isDryRun If true, the function will not emit any events.758 * @param {boolean} isDryRun - If true, the function will not emit any events.
759 * @typedef {{worldInfoString: string, worldInfoBefore: string, worldInfoAfter: string, worldInfoExamples: any[], worldInfoDepth: any[], anBefore: any[], anAfter: any[]}} WIPromptResult759 * @typedef {object} WIPromptResult
760 * @property {string} worldInfoString - Complete world info string
761 * @property {string} worldInfoBefore - World info that goes before the prompt
762 * @property {string} worldInfoAfter - World info that goes after the prompt
763 * @property {Array} worldInfoExamples - Array of example entries
764 * @property {Array} worldInfoDepth - Array of depth entries
765 * @property {Array} anBefore - Array of entries before Author's Note
766 * @property {Array} anAfter - Array of entries after Author's Note
760 * @returns {Promise<WIPromptResult>} The world info string and depth.767 * @returns {Promise<WIPromptResult>} The world info string and depth.
761 */768 */
762export async function getWorldInfoPrompt(chat, maxContext, isDryRun) {769export async function getWorldInfoPrompt(chat, maxContext, isDryRun) {
@@ -3864,7 +3871,14 @@ function parseDecorators(content) {
3864 * @param {string[]} chat The chat messages to scan, in reverse order.3871 * @param {string[]} chat The chat messages to scan, in reverse order.
3865 * @param {number} maxContext The maximum context size of the generation.3872 * @param {number} maxContext The maximum context size of the generation.
3866 * @param {boolean} isDryRun Whether to perform a dry run.3873 * @param {boolean} isDryRun Whether to perform a dry run.
3867 * @typedef {{ worldInfoBefore: string, worldInfoAfter: string, EMEntries: any[], WIDepthEntries: any[], ANBeforeEntries: any[], ANAfterEntries: any[], allActivatedEntries: Set<any> }} WIActivated3874 * @typedef {object} WIActivated
3875 * @property {string} worldInfoBefore The world info before the chat.
3876 * @property {string} worldInfoAfter The world info after the chat.
3877 * @property {any[]} EMEntries The entries for examples.
3878 * @property {any[]} WIDepthEntries The depth entries.
3879 * @property {any[]} ANBeforeEntries The entries before Author's Note.
3880 * @property {any[]} ANAfterEntries The entries after Author's Note.
3881 * @property {Set<any>} allActivatedEntries All entries.
3868 * @returns {Promise<WIActivated>} The world info activated.3882 * @returns {Promise<WIActivated>} The world info activated.
3869 */3883 */
3870export async function checkWorldInfo(chat, maxContext, isDryRun) {3884export async function checkWorldInfo(chat, maxContext, isDryRun) {