mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-07 05:08:01 +01:00
Disallow multiple {{original}} macro substitutions
This commit is contained in:
parent
a9464daffa
commit
5f1e290bda
@ -2147,7 +2147,15 @@ function substituteParams(content, _name1, _name2, _original, _group, _replaceCh
|
|||||||
const environment = {};
|
const environment = {};
|
||||||
|
|
||||||
if (typeof _original === 'string') {
|
if (typeof _original === 'string') {
|
||||||
environment.original = _original;
|
let originalSubstituted = false;
|
||||||
|
environment.original = () => {
|
||||||
|
if (originalSubstituted) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
originalSubstituted = true;
|
||||||
|
return _original;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_replaceCharacterCard) {
|
if (_replaceCharacterCard) {
|
||||||
|
@ -221,8 +221,7 @@ export function evaluateMacros(content, env) {
|
|||||||
if (!Object.hasOwn(env, varName)) continue;
|
if (!Object.hasOwn(env, varName)) continue;
|
||||||
|
|
||||||
const param = env[varName];
|
const param = env[varName];
|
||||||
const paramValue = typeof param === 'function' ? param() : param;
|
content = content.replace(new RegExp(`{{${varName}}}`, 'gi'), param);
|
||||||
content = content.replace(new RegExp(`{{${varName}}}`, 'gi'), paramValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content = content.replace(/{{maxPrompt}}/gi, () => String(getMaxContextSize()));
|
content = content.replace(/{{maxPrompt}}/gi, () => String(getMaxContextSize()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user