mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add {{lastGenerationType}} macro
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Handlebars, moment, seedrandom, droll } from '../lib.js';
|
||||
import { chat, chat_metadata, main_api, getMaxContextSize, getCurrentChatId, substituteParams } from '../script.js';
|
||||
import { chat, chat_metadata, main_api, getMaxContextSize, getCurrentChatId, substituteParams, eventSource, event_types } from '../script.js';
|
||||
import { timestampToMoment, isDigitsOnly, getStringHash, escapeRegex, uuidv4 } from './utils.js';
|
||||
import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
|
||||
import { getInstructMacros } from './instruct-mode.js';
|
||||
@ -521,3 +521,22 @@ export function evaluateMacros(content, env, postProcessFn) {
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
export function initMacros() {
|
||||
function initLastGenerationType() {
|
||||
let lastGenerationType = '';
|
||||
|
||||
MacrosParser.registerMacro('lastGenerationType', () => lastGenerationType);
|
||||
|
||||
eventSource.on(event_types.GENERATION_STARTED, (type, _params, isDryRun) => {
|
||||
if (isDryRun) return;
|
||||
lastGenerationType = type || 'normal';
|
||||
});
|
||||
|
||||
eventSource.on(event_types.CHAT_CHANGED, () => {
|
||||
lastGenerationType = '';
|
||||
});
|
||||
}
|
||||
|
||||
initLastGenerationType();
|
||||
}
|
||||
|
Reference in New Issue
Block a user