Update ext.macro calls in built-in extensions
This commit is contained in:
parent
bda4958cb3
commit
b22bc47c4f
|
@ -2323,7 +2323,7 @@ export function scrollChatToBottom() {
|
|||
* @param {Record<string,any>} additionalMacro - Additional environment variables for substitution.
|
||||
* @returns {string} The string with substituted parameters.
|
||||
*/
|
||||
export function substituteParamsExtended(content, additionalMacro) {
|
||||
export function substituteParamsExtended(content, additionalMacro = {}) {
|
||||
return substituteParams(content, undefined, undefined, undefined, undefined, true, additionalMacro);
|
||||
}
|
||||
|
||||
|
@ -7725,6 +7725,8 @@ window['SillyTavern'].getContext = function () {
|
|||
activateSendButtons,
|
||||
deactivateSendButtons,
|
||||
saveReply,
|
||||
substituteParams,
|
||||
substituteParamsExtended,
|
||||
registerSlashCommand: registerSlashCommand,
|
||||
executeSlashCommands: executeSlashCommands,
|
||||
timestampToMoment: timestampToMoment,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { getBase64Async, isTrueBoolean, saveBase64AsFile } from '../../utils.js';
|
||||
import { getContext, getApiUrl, doExtrasFetch, extension_settings, modules, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||
import { callPopup, getRequestHeaders, saveSettingsDebounced, substituteParams } from '../../../script.js';
|
||||
import { callPopup, getRequestHeaders, saveSettingsDebounced, substituteParamsExtended } from '../../../script.js';
|
||||
import { getMessageTimeStamp } from '../../RossAscends-mods.js';
|
||||
import { SECRET_KEYS, secret_state } from '../../secrets.js';
|
||||
import { getMultimodalCaption } from '../shared.js';
|
||||
|
@ -95,7 +95,7 @@ async function sendCaptionedMessage(caption, image) {
|
|||
template += ' {{caption}}';
|
||||
}
|
||||
|
||||
let messageText = substituteParams(template).replace(/{{caption}}/i, caption);
|
||||
let messageText = substituteParamsExtended(template, { caption: caption });
|
||||
|
||||
if (extension_settings.caption.refine_mode) {
|
||||
messageText = await callPopup(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { callPopup, eventSource, event_types, generateQuietPrompt, getRequestHeaders, online_status, saveSettingsDebounced, substituteParams } from '../../../script.js';
|
||||
import { callPopup, eventSource, event_types, generateQuietPrompt, getRequestHeaders, online_status, saveSettingsDebounced, substituteParams, substituteParamsExtended } from '../../../script.js';
|
||||
import { dragElement, isMobile } from '../../RossAscends-mods.js';
|
||||
import { getContext, getApiUrl, modules, extension_settings, ModuleWorkerWrapper, doExtrasFetch, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||
import { loadMovingUIState, power_user } from '../../power-user.js';
|
||||
|
@ -1008,8 +1008,7 @@ async function getLlmPrompt(labels) {
|
|||
}
|
||||
|
||||
const labelsString = labels.map(x => `"${x}"`).join(', ');
|
||||
const prompt = substituteParams(String(extension_settings.expressions.llmPrompt))
|
||||
.replace(/{{labels}}/gi, labelsString);
|
||||
const prompt = substituteParamsExtended(String(extension_settings.expressions.llmPrompt), { labels: labelsString });
|
||||
return prompt;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
generateQuietPrompt,
|
||||
is_send_press,
|
||||
saveSettingsDebounced,
|
||||
substituteParams,
|
||||
substituteParamsExtended,
|
||||
generateRaw,
|
||||
getMaxContextSize,
|
||||
} from '../../../script.js';
|
||||
|
@ -43,8 +43,7 @@ const formatMemoryValue = function (value) {
|
|||
value = value.trim();
|
||||
|
||||
if (extension_settings.memory.template) {
|
||||
let result = extension_settings.memory.template.replace(/{{summary}}/i, value);
|
||||
return substituteParams(result);
|
||||
return substituteParamsExtended(extension_settings.memory.template, { summary: value });
|
||||
} else {
|
||||
return `Summary: ${value}`;
|
||||
}
|
||||
|
@ -447,7 +446,7 @@ async function summarizeCallback(args, text) {
|
|||
}
|
||||
|
||||
const source = args.source || extension_settings.memory.source;
|
||||
const prompt = substituteParams((resolveVariable(args.prompt) || extension_settings.memory.prompt)?.replace(/{{words}}/gi, extension_settings.memory.promptWords));
|
||||
const prompt = substituteParamsExtended((resolveVariable(args.prompt) || extension_settings.memory.prompt), { words: extension_settings.memory.promptWords });
|
||||
|
||||
try {
|
||||
switch (source) {
|
||||
|
@ -534,7 +533,7 @@ async function summarizeChatMain(context, force, skipWIAN) {
|
|||
}
|
||||
|
||||
console.log('Summarizing chat, messages since last summary: ' + messagesSinceLastSummary, 'words since last summary: ' + wordsSinceLastSummary);
|
||||
const prompt = extension_settings.memory.prompt?.replace(/{{words}}/gi, extension_settings.memory.promptWords);
|
||||
const prompt = substituteParamsExtended(extension_settings.memory.prompt, { words: extension_settings.memory.promptWords });
|
||||
|
||||
if (!prompt) {
|
||||
console.debug('Summarization prompt is empty. Skipping summarization.');
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
setExtensionPrompt,
|
||||
substituteParams,
|
||||
generateRaw,
|
||||
substituteParamsExtended,
|
||||
} from '../../../script.js';
|
||||
import {
|
||||
ModuleWorkerWrapper,
|
||||
|
@ -441,7 +442,7 @@ async function injectDataBankChunks(queryText, collectionIds) {
|
|||
return;
|
||||
}
|
||||
|
||||
const insertedText = substituteParams(settings.file_template_db.replace(/{{text}}/i, textResult));
|
||||
const insertedText = substituteParamsExtended(settings.file_template_db, { text: textResult });
|
||||
setExtensionPrompt(EXTENSION_PROMPT_TAG_DB, insertedText, settings.file_position_db, settings.file_depth_db, settings.include_wi, settings.file_depth_role_db);
|
||||
} catch (error) {
|
||||
console.error('Vectors: Failed to insert Data Bank chunks', error);
|
||||
|
@ -592,7 +593,7 @@ async function rearrangeChat(chat) {
|
|||
function getPromptText(queriedMessages) {
|
||||
const queriedText = queriedMessages.map(x => collapseNewlines(`${x.name}: ${x.mes}`).trim()).join('\n\n');
|
||||
console.log('Vectors: relevant past messages found.\n', queriedText);
|
||||
return substituteParams(settings.template.replace(/{{text}}/i, queriedText));
|
||||
return substituteParamsExtended(settings.template, { text: queriedText });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue