Better WI type readability, fixed clone and type opeators.
| @@ -710,7 +710,7 @@ export function formatWorldInfo(value, { wiFormat = null } = {}) { | ||
| 710 | 710 | return ''; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | const format = wiFormat ||?? oai_settings.wi_format; |
| 714 | 714 | |
| 715 | 715 | if (!format.trim()) { |
| 716 | 716 | return value; |
| @@ -1992,7 +1992,7 @@ export function fuzzySearchGroups(searchValue, fuzzySearchCaches = null) { | ||
| 1992 | 1992 | */ |
| 1993 | 1993 | export function renderStoryString(params, { customStoryString = null, customInstructSettings = null } = {}) { |
| 1994 | 1994 | try { |
| 1995 | 1995 | const storyString = structuredClone(customStoryString ?? power_user.context.story_string); |
| 1996 | 1996 | const instructSettings = customInstructSettings ?? power_user.instruct; |
| 1997 | 1997 | |
| 1998 | 1998 | // Validate and log possible warnings/errors |
| @@ -753,10 +753,17 @@ export const worldInfoCache = new StructuredCloneMap({ cloneOnGet: true, cloneOn | ||
| 753 | 753 | |
| 754 | 754 | /** |
| 755 | 755 | * Gets the world info based on chat messages. |
| 756 | 756 | * @param {string[]} chat - The chat messages to scan, in reverse order. |
| 757 | 757 | * @param {number} maxContext - The maximum context size of the generation. |
| 758 | 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[]}} WIPromptResult | |
| 759 | + * @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 | 767 | * @returns {Promise<WIPromptResult>} The world info string and depth. |
| 761 | 768 | */ |
| 762 | 769 | export async function getWorldInfoPrompt(chat, maxContext, isDryRun) { |
| @@ -3864,7 +3871,14 @@ function parseDecorators(content) { | ||
| 3864 | 3871 | * @param {string[]} chat The chat messages to scan, in reverse order. |
| 3865 | 3872 | * @param {number} maxContext The maximum context size of the generation. |
| 3866 | 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> }} WIActivated | |
| 3874 | + * @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 | 3882 | * @returns {Promise<WIActivated>} The world info activated. |
| 3869 | 3883 | */ |
| 3870 | 3884 | export async function checkWorldInfo(chat, maxContext, isDryRun) { |