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:
@ -242,7 +242,7 @@ import { BulkEditOverlay, CharacterContextMenu } from './scripts/BulkEditOverlay
|
|||||||
import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels, loadTabbyModels } from './scripts/textgen-models.js';
|
import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels, loadTabbyModels } from './scripts/textgen-models.js';
|
||||||
import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId, preserveNeutralChat, restoreNeutralChat } from './scripts/chats.js';
|
import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId, preserveNeutralChat, restoreNeutralChat } from './scripts/chats.js';
|
||||||
import { initPresetManager } from './scripts/preset-manager.js';
|
import { initPresetManager } from './scripts/preset-manager.js';
|
||||||
import { MacrosParser, evaluateMacros, getLastMessageId } from './scripts/macros.js';
|
import { MacrosParser, evaluateMacros, getLastMessageId, initMacros } from './scripts/macros.js';
|
||||||
import { currentUser, setUserControls } from './scripts/user.js';
|
import { currentUser, setUserControls } from './scripts/user.js';
|
||||||
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup, fixToastrForDialogs } from './scripts/popup.js';
|
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup, fixToastrForDialogs } from './scripts/popup.js';
|
||||||
import { renderTemplate, renderTemplateAsync } from './scripts/templates.js';
|
import { renderTemplate, renderTemplateAsync } from './scripts/templates.js';
|
||||||
@ -957,6 +957,7 @@ async function firstLoadInit() {
|
|||||||
initDynamicStyles();
|
initDynamicStyles();
|
||||||
initTags();
|
initTags();
|
||||||
initBookmarks();
|
initBookmarks();
|
||||||
|
initMacros();
|
||||||
await getUserAvatars(true, user_avatar);
|
await getUserAvatars(true, user_avatar);
|
||||||
await getCharacters();
|
await getCharacters();
|
||||||
await getBackgrounds();
|
await getBackgrounds();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Handlebars, moment, seedrandom, droll } from '../lib.js';
|
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 { timestampToMoment, isDigitsOnly, getStringHash, escapeRegex, uuidv4 } from './utils.js';
|
||||||
import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
|
import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
|
||||||
import { getInstructMacros } from './instruct-mode.js';
|
import { getInstructMacros } from './instruct-mode.js';
|
||||||
@ -521,3 +521,22 @@ export function evaluateMacros(content, env, postProcessFn) {
|
|||||||
|
|
||||||
return content;
|
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();
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<li><tt>{{noop}}</tt> – <span data-i18n="help_macros_4">no operation, just an empty string.</span></li>
|
<li><tt>{{noop}}</tt> – <span data-i18n="help_macros_4">no operation, just an empty string.</span></li>
|
||||||
<li><tt>{{original}}</tt> – <span data-i18n="help_macros_5">global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</span></li>
|
<li><tt>{{original}}</tt> – <span data-i18n="help_macros_5">global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</span></li>
|
||||||
<li><tt>{{input}}</tt> – <span data-i18n="help_macros_6">the user input</span></li>
|
<li><tt>{{input}}</tt> – <span data-i18n="help_macros_6">the user input</span></li>
|
||||||
|
<li><tt>{{lastGenerationType}}</tt> - <span>the type of the last queued generation request. Empty if no generations were performed yet or the active chat was switched. Possible values: "normal", "impersonate", "regenerate", "quiet", "swipe", "continue".</span></li>
|
||||||
<li><tt>{{charPrompt}}</tt> – <span data-i18n="help_macros_7">the Character's Main Prompt override</span></li>
|
<li><tt>{{charPrompt}}</tt> – <span data-i18n="help_macros_7">the Character's Main Prompt override</span></li>
|
||||||
<li><tt>{{charInstruction}}</tt> – <span data-i18n="help_macros_8">the Character's Post-History Instructions override</span></li>
|
<li><tt>{{charInstruction}}</tt> – <span data-i18n="help_macros_8">the Character's Post-History Instructions override</span></li>
|
||||||
<li><tt>{{description}}</tt> – <span data-i18n="help_macros_9">the Character's Description</span></li>
|
<li><tt>{{description}}</tt> – <span data-i18n="help_macros_9">the Character's Description</span></li>
|
||||||
|
Reference in New Issue
Block a user