mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add {{newline}} and {{pipe}} macros
This commit is contained in:
@ -2010,6 +2010,7 @@ function substituteParams(content, _name1, _name2, _original, _group, _replaceCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
content = replaceVariableMacros(content);
|
content = replaceVariableMacros(content);
|
||||||
|
content = content.replace(/{{newline}}/gi, "\n");
|
||||||
content = content.replace(/{{input}}/gi, String($('#send_textarea').val()));
|
content = content.replace(/{{input}}/gi, String($('#send_textarea').val()));
|
||||||
|
|
||||||
if (_replaceCharacterCard) {
|
if (_replaceCharacterCard) {
|
||||||
|
@ -1014,7 +1014,12 @@ async function executeSlashCommands(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.debug('Slash command executing:', result);
|
console.debug('Slash command executing:', result);
|
||||||
const unnamedArg = result.value || pipeResult;
|
let unnamedArg = result.value || pipeResult;
|
||||||
|
|
||||||
|
if (typeof unnamedArg === 'string' && /{{pipe}}/i.test(unnamedArg)) {
|
||||||
|
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult);
|
||||||
|
}
|
||||||
|
|
||||||
pipeResult = await result.command.callback(result.args, unnamedArg);
|
pipeResult = await result.command.callback(result.args, unnamedArg);
|
||||||
|
|
||||||
if (result.command.interruptsGeneration) {
|
if (result.command.interruptsGeneration) {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
System-wide Replacement Macros (in order of evaluation):
|
System-wide Replacement Macros (in order of evaluation):
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><tt>{{pipe}}</tt> – only for slash command batching. Replaced with the returned result of the previous command.</li>
|
||||||
|
<li><tt>{{newline}}</tt> – just inserts a newline.</li>
|
||||||
<li><tt>{{original}}</tt> – global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</li>
|
<li><tt>{{original}}</tt> – global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</li>
|
||||||
<li><tt>{{input}}</tt> – the user input</li>
|
<li><tt>{{input}}</tt> – the user input</li>
|
||||||
<li><tt>{{charPrompt}}</tt> – the Character's Main Prompt override</li>
|
<li><tt>{{charPrompt}}</tt> – the Character's Main Prompt override</li>
|
||||||
|
Reference in New Issue
Block a user