mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
New exports
This commit is contained in:
@ -1985,15 +1985,21 @@ export function fuzzySearchGroups(searchValue, fuzzySearchCaches = null) {
|
||||
/**
|
||||
* Renders a story string template with the given parameters.
|
||||
* @param {object} params Template parameters.
|
||||
* @param {object} [options] Additional options.
|
||||
* @param {string} [options.customStoryString] Custom story string template.
|
||||
* @param {InstructSettings} [options.customInstructSettings] Custom instruct settings.
|
||||
* @returns {string} The rendered story string.
|
||||
*/
|
||||
export function renderStoryString(params) {
|
||||
export function renderStoryString(params, { customStoryString = null, customInstructSettings = null } = {}) {
|
||||
try {
|
||||
const storyString = customStoryString ?? power_user.context.story_string;
|
||||
const instructSettings = customInstructSettings ?? power_user.instruct;
|
||||
|
||||
// Validate and log possible warnings/errors
|
||||
validateStoryString(power_user.context.story_string, params);
|
||||
validateStoryString(storyString, params);
|
||||
|
||||
// compile the story string template into a function, with no HTML escaping
|
||||
const compiledTemplate = Handlebars.compile(power_user.context.story_string, { noEscape: true });
|
||||
const compiledTemplate = Handlebars.compile(storyString, { noEscape: true });
|
||||
|
||||
// render the story string template with the given params
|
||||
let output = compiledTemplate(params);
|
||||
@ -2006,7 +2012,7 @@ export function renderStoryString(params) {
|
||||
|
||||
// add a newline to the end of the story string if it doesn't have one
|
||||
if (output.length > 0 && !output.endsWith('\n')) {
|
||||
if (!power_user.instruct.enabled || power_user.instruct.wrap) {
|
||||
if (!instructSettings.enabled || instructSettings.wrap) {
|
||||
output += '\n';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user