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 = {};
|
||||
|
||||
if (typeof _original === 'string') {
|
||||
environment.original = _original;
|
||||
let originalSubstituted = false;
|
||||
environment.original = () => {
|
||||
if (originalSubstituted) {
|
||||
return '';
|
||||
}
|
||||
|
||||
originalSubstituted = true;
|
||||
return _original;
|
||||
};
|
||||
}
|
||||
|
||||
if (_replaceCharacterCard) {
|
||||
|
|
|
@ -221,8 +221,7 @@ export function evaluateMacros(content, env) {
|
|||
if (!Object.hasOwn(env, varName)) continue;
|
||||
|
||||
const param = env[varName];
|
||||
const paramValue = typeof param === 'function' ? param() : param;
|
||||
content = content.replace(new RegExp(`{{${varName}}}`, 'gi'), paramValue);
|
||||
content = content.replace(new RegExp(`{{${varName}}}`, 'gi'), param);
|
||||
}
|
||||
|
||||
content = content.replace(/{{maxPrompt}}/gi, () => String(getMaxContextSize()));
|
||||
|
|
Loading…
Reference in New Issue