mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Better WI type readability, fixed clone and type opeators.
This commit is contained in:
@@ -710,7 +710,7 @@ export function formatWorldInfo(value, { wiFormat = null } = {}) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const format = wiFormat || oai_settings.wi_format;
|
const format = wiFormat ?? oai_settings.wi_format;
|
||||||
|
|
||||||
if (!format.trim()) {
|
if (!format.trim()) {
|
||||||
return value;
|
return value;
|
||||||
|
@@ -1992,7 +1992,7 @@ export function fuzzySearchGroups(searchValue, fuzzySearchCaches = null) {
|
|||||||
*/
|
*/
|
||||||
export function renderStoryString(params, { customStoryString = null, customInstructSettings = null } = {}) {
|
export function renderStoryString(params, { customStoryString = null, customInstructSettings = null } = {}) {
|
||||||
try {
|
try {
|
||||||
const storyString = customStoryString ?? power_user.context.story_string;
|
const storyString = structuredClone(customStoryString ?? power_user.context.story_string);
|
||||||
const instructSettings = customInstructSettings ?? power_user.instruct;
|
const instructSettings = customInstructSettings ?? power_user.instruct;
|
||||||
|
|
||||||
// Validate and log possible warnings/errors
|
// Validate and log possible warnings/errors
|
||||||
|
@@ -753,10 +753,17 @@ export const worldInfoCache = new StructuredCloneMap({ cloneOnGet: true, cloneOn
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the world info based on chat messages.
|
* Gets the world info based on chat messages.
|
||||||
* @param {string[]} chat The chat messages to scan, in reverse order.
|
* @param {string[]} chat - The chat messages to scan, in reverse order.
|
||||||
* @param {number} maxContext The maximum context size of the generation.
|
* @param {number} maxContext - The maximum context size of the generation.
|
||||||
* @param {boolean} isDryRun If true, the function will not emit any events.
|
* @param {boolean} isDryRun - If true, the function will not emit any events.
|
||||||
* @typedef {{worldInfoString: string, worldInfoBefore: string, worldInfoAfter: string, worldInfoExamples: any[], worldInfoDepth: any[], anBefore: any[], anAfter: any[]}} WIPromptResult
|
* @typedef {object} WIPromptResult
|
||||||
|
* @property {string} worldInfoString - Complete world info string
|
||||||
|
* @property {string} worldInfoBefore - World info that goes before the prompt
|
||||||
|
* @property {string} worldInfoAfter - World info that goes after the prompt
|
||||||
|
* @property {Array} worldInfoExamples - Array of example entries
|
||||||
|
* @property {Array} worldInfoDepth - Array of depth entries
|
||||||
|
* @property {Array} anBefore - Array of entries before Author's Note
|
||||||
|
* @property {Array} anAfter - Array of entries after Author's Note
|
||||||
* @returns {Promise<WIPromptResult>} The world info string and depth.
|
* @returns {Promise<WIPromptResult>} The world info string and depth.
|
||||||
*/
|
*/
|
||||||
export async function getWorldInfoPrompt(chat, maxContext, isDryRun) {
|
export async function getWorldInfoPrompt(chat, maxContext, isDryRun) {
|
||||||
@@ -3864,7 +3871,14 @@ function parseDecorators(content) {
|
|||||||
* @param {string[]} chat The chat messages to scan, in reverse order.
|
* @param {string[]} chat The chat messages to scan, in reverse order.
|
||||||
* @param {number} maxContext The maximum context size of the generation.
|
* @param {number} maxContext The maximum context size of the generation.
|
||||||
* @param {boolean} isDryRun Whether to perform a dry run.
|
* @param {boolean} isDryRun Whether to perform a dry run.
|
||||||
* @typedef {{ worldInfoBefore: string, worldInfoAfter: string, EMEntries: any[], WIDepthEntries: any[], ANBeforeEntries: any[], ANAfterEntries: any[], allActivatedEntries: Set<any> }} WIActivated
|
* @typedef {object} WIActivated
|
||||||
|
* @property {string} worldInfoBefore The world info before the chat.
|
||||||
|
* @property {string} worldInfoAfter The world info after the chat.
|
||||||
|
* @property {any[]} EMEntries The entries for examples.
|
||||||
|
* @property {any[]} WIDepthEntries The depth entries.
|
||||||
|
* @property {any[]} ANBeforeEntries The entries before Author's Note.
|
||||||
|
* @property {any[]} ANAfterEntries The entries after Author's Note.
|
||||||
|
* @property {Set<any>} allActivatedEntries All entries.
|
||||||
* @returns {Promise<WIActivated>} The world info activated.
|
* @returns {Promise<WIActivated>} The world info activated.
|
||||||
*/
|
*/
|
||||||
export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||||
|
Reference in New Issue
Block a user