mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add {{trim}} macro
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"story_string": "<|im_start|>system\n{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}<|im_end|>",
|
"story_string": "<|im_start|>system\n{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}}<|im_end|>",
|
||||||
"example_separator": "",
|
"example_separator": "",
|
||||||
"chat_start": "",
|
"chat_start": "",
|
||||||
"use_stop_strings": false,
|
"use_stop_strings": false,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"story_string": "[INST] <<SYS>>\n{{#if system}}{{system}}\n<</SYS>>\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}} [/INST]",
|
"story_string": "[INST] <<SYS>>\n{{#if system}}{{system}}\n<</SYS>>\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}} [/INST]",
|
||||||
"example_separator": "",
|
"example_separator": "",
|
||||||
"chat_start": "",
|
"chat_start": "",
|
||||||
"use_stop_strings": false,
|
"use_stop_strings": false,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"story_string": "[INST] {{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}} [/INST]",
|
"story_string": "[INST] {{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}} [/INST]",
|
||||||
"example_separator": "Examples:",
|
"example_separator": "Examples:",
|
||||||
"chat_start": "",
|
"chat_start": "",
|
||||||
"use_stop_strings": false,
|
"use_stop_strings": false,
|
||||||
|
@ -4,6 +4,9 @@ import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
|
|||||||
import { replaceInstructMacros } from './instruct-mode.js';
|
import { replaceInstructMacros } from './instruct-mode.js';
|
||||||
import { replaceVariableMacros } from './variables.js';
|
import { replaceVariableMacros } from './variables.js';
|
||||||
|
|
||||||
|
// Register any macro that you want to leave in the compiled story string
|
||||||
|
Handlebars.registerHelper('trim', () => '{{trim}}');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the last message in the chat.
|
* Returns the ID of the last message in the chat.
|
||||||
* @returns {string} The ID of the last message in the chat.
|
* @returns {string} The ID of the last message in the chat.
|
||||||
@ -257,6 +260,7 @@ export function evaluateMacros(content, env) {
|
|||||||
content = replaceInstructMacros(content);
|
content = replaceInstructMacros(content);
|
||||||
content = replaceVariableMacros(content);
|
content = replaceVariableMacros(content);
|
||||||
content = content.replace(/{{newline}}/gi, '\n');
|
content = content.replace(/{{newline}}/gi, '\n');
|
||||||
|
content = content.replace(/\n*{{trim}}\n*/gi, '');
|
||||||
content = content.replace(/{{input}}/gi, () => String($('#send_textarea').val()));
|
content = content.replace(/{{input}}/gi, () => String($('#send_textarea').val()));
|
||||||
|
|
||||||
// Substitute passed-in variables
|
// Substitute passed-in variables
|
||||||
|
Reference in New Issue
Block a user