Merge remote-tracking branch 'alpin/staging' into sampler_order

86b42477673a2f27019562e0308092586d5ced29

AlpinDale <alpindale@gmail.com>

11 files changed, +154 -66Ignore whitespace
package-lock.json+2 -2
@@ -1,12 +1,12 @@
11{
22 "name": "sillytavern",
33 "version": "1.12.78",
44 "lockfileVersion": 3,
55 "requires": true,
66 "packages": {
77 "": {
88 "name": "sillytavern",
99 "version": "1.12.78",
1010 "hasInstallScript": true,
1111 "license": "AGPL-3.0",
1212 "dependencies": {
package.json+1 -1
@@ -84,7 +84,7 @@
8484 "type": "git",
8585 "url": "https://github.com/SillyTavern/SillyTavern.git"
8686 },
8787 "version": "1.12.78",
8888 "scripts": {
8989 "start": "node server.js",
9090 "start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js",
public/index.html+82 -43
@@ -820,8 +820,8 @@
820820 </div>
821821 </div>
822822 <div class="range-block m-t-1">
823823 <div class="range-block-title openai_restorable" data-i18n="World Info Format Template">
824824 <span data-i18n="World Info Format Template">World Info format template</span>
825825 <div id="wi_format_restore" data-i18n="[title]Restore default format" title="Restore default format" class="right_menu_button">
826826 <div class="fa-solid fa-clock-rotate-left"></div>
827827 </div>
@@ -1524,15 +1524,15 @@
15241524 <div class="">
15251525 <label class="checkbox_label" for="early_stopping_textgenerationwebui">
15261526 <input type="checkbox" id="early_stopping_textgenerationwebui" />
15271527 <small data-i18n="Early Stopping">Early Stopping</small>
15281528 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Controls the stopping condition for beam search. If checked, the generation stops as soon as there are '# of Beams' sequences. If not checked, a heuristic is applied and the generation is stopped when it's very unlikely to find better candidates." title="Controls the stopping condition for beam search. If checked, the generation stops as soon as there are '# of Beams' sequences. If not checked, a heuristic is applied and the generation is stopped when it's very unlikely to find better candidates."></div>
1529- </small>
15301529 </label>
15311530 </div>
15321531 </div>
15331532 </div>
15341533 <div data-tg-type="ooba" id="contrastiveSearchBlock" name="contrastiveSearchBlock" class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0">
15351534 <h4 class="textAlignCenter" data-i18n="Contrastive search">Contrastive Search
1535+ <span data-i18n="Contrastive search">Contrastive Search</span>
15361536 <div class=" fa-solid fa-circle-info opacity50p " data-i18n="Contrastive_search_txt" title="A sampler that encourages diversity while maintaining coherence, by exploiting the isotropicity of the representation space of most LLMs. For details, see the paper A Contrastive Framework for Neural Text Generation by Su et al. (2022)."></div>
15371537 </h4>
15381538 <div class="alignitemscenter flex-container flexFlowColumn wide100p gap0">
@@ -1566,9 +1566,8 @@
15661566 </label>
15671567 <label data-tg-type="vllm, aphrodite, infermaticai" class="checkbox_label" for="ignore_eos_token_textgenerationwebui">
15681568 <input type="checkbox" id="ignore_eos_token_textgenerationwebui" />
15691569 <small data-i18n="Ignore EOS Token">Ignore EOS Token</small>
15701570 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Ignore the EOS Token even if it generates." title="Ignore the EOS Token even if it generates."></div>
1571- </small>
15721571 </label>
15731572 <label class="checkbox_label flexGrow flexShrink" for="skip_special_tokens_textgenerationwebui">
15741573 <input type="checkbox" id="skip_special_tokens_textgenerationwebui" />
@@ -1629,7 +1628,8 @@
16291628 </div>
16301629 <div id="cfg_block_ooba" data-tg-type="ooba, tabby" class="wide100p">
16311630 <hr class="width100p">
16321631 <h4 data-i18n="CFG" class="textAlignCenter">CFG
1632+ <span data-i18n="CFG">CFG</span>
16331633 <div class="margin5 fa-solid fa-circle-info opacity50p " data-i18n="[title]Classifier Free Guidance. More helpful tip coming soon" title="Classifier Free Guidance. More helpful tip coming soon."></div>
16341634 </h4>
16351635 <div class="alignitemscenter flex-container flexFlowColumn flexShrink gap0">
@@ -2032,8 +2032,10 @@
20322032 <div id="logit_bias_openai" class="range-block-title openai_restorable" data-i18n="Logit Bias">
20332033 Logit Bias
20342034 </div>
20352035 <div class="toggle-description justifyLeft" data-i18n="Helps to ban or reenforce the usage of certain words">
20362036 <span data-i18n="Helps to ban or reinforcereenforce the usage of certain tokens.words">Helps Confirmto tokenban parsingor withreinforce <athe target="_blank"usage href="https://platform.openaiof certain tokens.com/tokenizer/">Tokenizer</aspan>.
2037+ <span data-i18n="Confirm token parsing with">Confirm token parsing with</span>
2038+ <a target="_blank" href="https://platform.openai.com/tokenizer/" data-i18n="Tokenizer">Tokenizer</a>.
20372039 </div>
20382040 <div class="openai_logit_bias_preset_form">
20392041 <select id="openai_logit_bias_preset">
@@ -2334,8 +2336,8 @@
23342336 <div data-tg-type="mancer" class="flex-container flexFlowColumn">
23352337 <div class="flex-container flexFlowColumn">
23362338 </div>
2337- <h4 data-i18n="Mancer API key">
2339+ <h4>
2338- Mancer API key
2340+ <span data-i18n="Mancer API key">Mancer API key</span>
23392341 <a href="https://mancer.tech/" class="notes-link" target="_blank">
23402342 <span class="fa-solid fa-circle-question note-link-span"></span>
23412343 </a>
@@ -2631,15 +2633,21 @@
26312633 <input id="koboldcpp_api_url_text" class="text_pole wide100p" value="" autocomplete="off" data-server-history="koboldcpp">
26322634 </div>
26332635 </div>
2636+ <div class="flex-container flexFlowColumn marginTopBot5">
2637+ <label data-tg-type="ooba" class="checkbox_label" for="bypass_status_check_textgenerationwebui">
2638+ <input type="checkbox" id="bypass_status_check_textgenerationwebui" />
2639+ <span data-i18n="Bypass status check">Bypass status check</span>
2640+ </label>
2641+ <label data-tg-type="koboldcpp, llamacpp" class="checkbox_label" for="context_size_derived">
2642+ <input type="checkbox" id="context_size_derived" />
2643+ <span data-i18n="Derive context size from backend">Derive context size from backend</span>
2644+ </label>
2645+ </div>
26342646 <div class="flex-container">
26352647 <div id="api_button_textgenerationwebui" class="api_button menu_button menu_button_icon" type="submit" data-i18n="Connect" data-server-connect="ooba_blocking,vllm,aphrodite,tabby,koboldcpp,ollama,llamacpp,huggingface">Connect</div>
26362648 <div data-tg-type="openrouter" class="menu_button menu_button_icon openrouter_authorize" title="Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai" data-i18n="Authorize;[title]Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai">Authorize</div>
26372649 <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>
26382650 </div>
2639- <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="bypass_status_check_textgenerationwebui">
2640- <input type="checkbox" id="bypass_status_check_textgenerationwebui" />
2641- <span data-i18n="Bypass status check">Bypass status check</span>
2642- </label>
26432651 </form>
26442652 <div class="online_status">
26452653 <div class="online_status_indicator"></div>
@@ -2682,8 +2690,9 @@
26822690 </div>
26832691 <div class="toggle-description justifyLeft">
26842692 <span data-i18n="Saved addresses and passwords.">
26852693 Saved addresses and passwords.<br>
26862694 </span>
2695+ <br>
26872696 </div>
26882697 <div class="openai_logit_bias_preset_form">
26892698 <select id="openai_proxy_preset">
@@ -2696,8 +2705,9 @@
26962705 </div>
26972706 <div class="toggle-description justifyLeft">
26982707 <span data-i18n="This will show up as your saved preset.">
26992708 This will show up as your saved preset.<br>
27002709 </span>
2710+ <br>
27012711 </div>
27022712 <div class="wide100p">
27032713 <input id="openai_reverse_proxy_name" type="text" class="text_pole" placeholder="..." />
@@ -2707,8 +2717,9 @@
27072717 </div>
27082718 <div class="toggle-description justifyLeft wide100p">
27092719 <span data-i18n="Alternative server URL (leave empty to use the default value).">
27102720 Alternative server URL (leave empty to use the default value).<br>
27112721 </span>
2722+ <br>
27122723 </div>
27132724 <div class="wide100p">
27142725 <input id="openai_reverse_proxy" type="text" class="text_pole" placeholder="https://api.openai.com/v1" />
@@ -2721,8 +2732,9 @@
27212732 </div>
27222733 <div class="toggle-description justifyLeft">
27232734 <span data-i18n="Will be used as a password for the proxy instead of API key.">
27242735 Will be used as a password for the proxy instead of API key.<br>
27252736 </span>
2737+ <br>
27262738 </div>
27272739 <div class="flex-container width100p">
27282740 <input id="openai_proxy_password" type="password" class="text_pole flex1" placeholder="" form="openai_form" autocomplete="off" />
@@ -3810,7 +3822,11 @@
38103822 <div id="wiTopBlock" class="flex-container">
38113823 <div id="WIMultiSelector" class="flex1 flex alignSelfStart range-block">
38123824 <div class="range-block-title justifyLeft">
3813- <span data-i18n="Active World(s) for all chats"><small>Active World(s) for all chats</small></span>
3825+ <span>
3826+ <small data-i18n="Active World(s) for all chats">
3827+ Active World(s) for all chats
3828+ </small>
3829+ </span>
38143830 </div>
38153831 <div class="range-block-range">
38163832 <select id="world_info" class="select2_multi_sameline" multiple>
@@ -4135,7 +4151,10 @@
41354151
41364152 <div class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0">
41374153 <small>
4138- <span data-i18n="Chat Width">Chat Width <i class="fa-solid fa-desktop"></i></span>
4154+ <span>
4155+ <span data-i18n="Chat Width">Chat Width</span>
4156+ <i class="fa-solid fa-desktop"></i>
4157+ </span>
41394158 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Width of the main chat window in % of screen width" title="Width of the main chat window in % of screen width"></div>
41404159 </small>
41414160 <input class="neo-range-slider" type="range" id="chat_width_slider" name="chat_width_slider" min="25" max="100" step="1">
@@ -4307,7 +4326,7 @@
43074326 <div id="reload_chat" class="menu_button whitespacenowrap" data-i18n="[title]Reload and redraw the currently open chat" title="Reload and redraw the currently open chat.">
43084327 <small data-i18n="Reload Chat">Reload Chat</small>
43094328 </div>
43104329 <div id="debug_menu" class="menu_button whitespacenowrap" data-i18n="Debug Menu">
43114330 <small data-i18n="Debug Menu">Debug Menu</small>
43124331 </div>
43134332 </div>
@@ -4426,8 +4445,10 @@
44264445 </div>
44274446 </div>
44284447 <div id="examples-behavior-block">
4429- <label data-i18n="Example Messages Behavior">
4448+ <label>
44304449 <small> data-i18n="Example Messages Behavior:</small">
4450+ Example Messages Behavior:
4451+ </small>
44314452 </label>
44324453 <select id="example_messages_behavior">
44334454 <option value="normal" data-i18n="Gradual push-out">Gradual push-out</option>
@@ -4591,7 +4612,9 @@
45914612 </label>
45924613 <div class="flex-container">
45934614 <div class="flex1" title="Determines how entries are found for autocomplete." data-i18n="[title]Determines how entries are found for autocomplete.">
4594- <label for="stscript_matching" data-i18n="Autocomplete Matching"><small>Matching</small></label>
4615+ <label for="stscript_matching">
4616+ <small data-i18n="Autocomplete Matching">Matching</small>
4617+ </label>
45954618 <select id="stscript_matching">
45964619 <option data-i18n="Starts with" value="strict">Starts with</option>
45974620 <option data-i18n="Includes" value="includes">Includes</option>
@@ -4599,7 +4622,9 @@
45994622 </select>
46004623 </div>
46014624 <div class="flex1" title="Sets the style of the autocomplete." data-i18n="[title]Sets the style of the autocomplete.">
4602- <label for="stscript_autocomplete_style" data-i18n="Autocomplete Style"><small>Style</small></label>
4625+ <label for="stscript_autocomplete_style">
4626+ <small data-i18n="Autocomplete Style">Style</small>
4627+ </label>
46034628 <div class="flex-container flexFlowRow alignItemsBaseline">
46044629 <select id="stscript_autocomplete_style">
46054630 <option data-i18n="Follow Theme" value="theme">Follow Theme</option>
@@ -4611,8 +4636,8 @@
46114636 </div>
46124637 </div>
46134638 <div title="Determines which keys select an item from the AutoComplete suggestions">
46144639 <label data-i18n="Keyboard">
46154640 <small data-i18n="Keyboard">Keyboard:</small>
46164641 </label>
46174642 <select id="stscript_autocomplete_select">
46184643 <option value="3" data-i18n="Select with Tab or Enter">Select with Tab or Enter</option>
@@ -4626,7 +4651,9 @@
46264651 <input class="neo-range-input" type="number" min="0.5" max="2" step="0.01" data-for="stscript_autocomplete_font_scale" id="stscript_autocomplete_font_scale_counter">
46274652 </div>
46284653 <div title="Sets the width of the autocomplete." data-i18n="[title]Sets the width of the autocomplete.">
4629- <label for="stscript_autocomplete_width" data-i18n="Autocomplete Width"><small>Width</small></label>
4654+ <label for="stscript_autocomplete_width">
4655+ <small data-i18n="Autocomplete Width">Width</small>
4656+ </label>
46304657 <div class="doubleRangeContainer">
46314658 <div class="doubleRangeInputContainer">
46324659 <input type="range" id="stscript_autocomplete_width_left" min="0" max="2" step="1">
@@ -4654,14 +4681,18 @@
46544681 <label><small data-i18n="Parser Flags">Parser Flags</small></label>
46554682 <label class="checkbox_label" title="Switch to stricter escaping, allowing all delimiting characters to be escaped with a backslash, and backslashes to be escaped as well." data-i18n="[title]Switch to stricter escaping, allowing all delimiting characters to be escaped with a backslash, and backslashes to be escaped as well.">
46564683 <input id="stscript_parser_flag_strict_escaping" type="checkbox" />
4657- <span data-i18n="STRICT_ESCAPING"><small>STRICT_ESCAPING</small></span>
4684+ <span>
4685+ <small data-i18n="STRICT_ESCAPING">STRICT_ESCAPING</small>
4686+ </span>
46584687 <a href="https://docs.sillytavern.app/usage/st-script/#strict-escaping" target="_blank" class="notes-link">
46594688 <span class="fa-solid fa-circle-question note-link-span"></span>
46604689 </a>
46614690 </label>
46624691 <label class="checkbox_label" title="Prevents {{getvar::}} {{getglobalvar::}} macros from having literal macro-like values auto-evaluated.&NewLine;e.g. &quot;{{newline}}&quot; remains as literal string &quot;{{newline}}&quot;&NewLine;&NewLine;(This is done by internally replacing {{getvar::}} {{getglobalvar::}} macros with scoped variables.)" data-i18n="[title]stscript_parser_flag_replace_getvar_label">
46634692 <input id="stscript_parser_flag_replace_getvar" type="checkbox" />
4664- <span data-i18n="REPLACE_GETVAR"><small>REPLACE_GETVAR</small></span>
4693+ <span>
4694+ <small data-i18n="REPLACE_GETVAR">REPLACE_GETVAR</small>
4695+ </span>
46654696 <a href="https://docs.sillytavern.app/usage/st-script/#replace-variable-macros" target="_blank" class="notes-link">
46664697 <span class="fa-solid fa-circle-question note-link-span"></span>
46674698 </a>
@@ -4792,10 +4823,12 @@
47924823 <div class="flex-container wide100p alignitemscenter spaceBetween flexNoGap">
47934824 <div class="flex-container alignItemsBaseline wide100p">
47944825 <div class="flex1 flex-container alignItemsBaseline">
47954826 <h3 class="margin0" data-i18n="Persona Management">Persona Management</h3>
4796- <a href="https://docs.sillytavern.app/usage/core-concepts/personas/" target="_blank" data-i18n="How do I use this?">
4827+ <span data-i18n="Persona Management">Persona Management</span>
4797- <span class="fa-solid fa-circle-question note-link-span"></span>
4828+ <a href="https://docs.sillytavern.app/usage/core-concepts/personas/" target="_blank">
4798- </a>
4829+ <span class="fa-solid fa-circle-question note-link-span"></span>
4830+ </a>
4831+ </h3>
47994832 </div>
48004833 <div class="flex-container">
48014834 <div class="menu_button menu_button_icon user_stats_button" data-i18n="[title]Click for stats!" title="Click for stats!">
@@ -5516,7 +5549,12 @@
55165549 <span data-i18n="Examples of dialogue" class="mdhotkey_location">Examples of dialogue</span>
55175550 <i class="editor_maximize fa-solid fa-maximize right_menu_button" data-for="mes_example_textarea" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
55185551 </h4>
5519- <h5 data-i18n="Important to set the character's writing style.">Important to set the character's writing style. <a href="https://docs.sillytavern.app/usage/core-concepts/characterdesign/#examples-of-dialogue" class="notes-link" target="_blank"><span class="fa-solid fa-circle-question note-link-span"></span></a></h5>
5552+ <h5>
5553+ <span data-i18n="Important to set the character's writing style.">Important to set the character's writing style.</span>
5554+ <a href="https://docs.sillytavern.app/usage/core-concepts/characterdesign/#examples-of-dialogue" class="notes-link" target="_blank">
5555+ <span class="fa-solid fa-circle-question note-link-span"></span>
5556+ </a>
5557+ </h5>
55205558 </div>
55215559 <textarea id="mes_example_textarea" class="flexGrow mdHotkeys" name="mes_example" data-i18n="[placeholder](Examples of chat dialog. Begin each example with START on a new line.)" placeholder="(Examples of chat dialog. Begin each example with &lt;START&gt; on a new line.)" form="form_create" rows="6"></textarea>
55225560 <div class="extension_token_counter">
@@ -5592,7 +5630,8 @@
55925630 <div class="character_world range-block flexFlowColumn flex-container">
55935631 <div class="range-block-title">
55945632 <h3>
55955633 <span data-i18n="Select a World Info file for"> Select a World Info file for <span class="character_name"></span></span>:
5634+ <span class="character_name"></span>:
55965635 </h3>
55975636 </div>
55985637 <h4 data-i18n="Primary Lorebook">Primary Lorebook</h4>
@@ -5893,7 +5932,7 @@
58935932 </div>
58945933 <div class="flex2 flex-container flexFlowColumn flexNoGap" data-i18n="[title]Sticky entries will stay active for N messages after being triggered." title="Sticky entries will stay active for N messages after being triggered.">
58955934 <div class="flex-container justifySpaceBetween marginBot5">
58965935 <small class="flex-container alignItemsBaseline" for="sticky" data-i18n="Sticky">
58975936 <span data-i18n="Sticky">
58985937 Sticky
58995938 </span>
@@ -5906,7 +5945,7 @@
59065945 </div>
59075946 <div class="flex2 flex-container flexFlowColumn flexNoGap" data-i18n="[title]Entries with a cooldown can't be activated N messages after being triggered." title="Entries with a cooldown can't be activated N messages after being triggered.">
59085947 <div class="flex-container justifySpaceBetween marginBot5">
59095948 <small class="flex-container alignItemsBaseline" for="cooldown" data-i18n="Cooldown">
59105949 <span data-i18n="Cooldown">
59115950 Cooldown
59125951 </span>
@@ -5919,7 +5958,7 @@
59195958 </div>
59205959 <div class="flex2 flex-container flexFlowColumn flexNoGap" data-i18n="[title]Entries with a delay can't be activated until there are N messages present in the chat." title="Entries with a delay can't be activated until there are N messages present in the chat.">
59215960 <div class="flex-container justifySpaceBetween marginBot5">
59225961 <small class="flex-container alignItemsBaseline" for="delay" data-i18n="Delay">
59235962 <span data-i18n="Delay">
59245963 Delay
59255964 </span>
public/script.js+19 -2
@@ -242,7 +242,7 @@ import { BulkEditOverlay, CharacterContextMenu } from './scripts/BulkEditOverlay
242242import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels, loadTabbyModels } from './scripts/textgen-models.js';
243243import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId, preserveNeutralChat, restoreNeutralChat } from './scripts/chats.js';
244244import { initPresetManager } from './scripts/preset-manager.js';
245245import { MacrosParser, evaluateMacros, getLastMessageId, initMacros } from './scripts/macros.js';
246246import { currentUser, setUserControls } from './scripts/user.js';
247247import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup, fixToastrForDialogs } from './scripts/popup.js';
248248import { renderTemplate, renderTemplateAsync } from './scripts/templates.js';
@@ -957,6 +957,7 @@ async function firstLoadInit() {
957957 initDynamicStyles();
958958 initTags();
959959 initBookmarks();
960+ initMacros();
960961 await getUserAvatars(true, user_avatar);
961962 await getCharacters();
962963 await getBackgrounds();
@@ -1238,8 +1239,9 @@ async function getStatusTextgen() {
12381239
12391240 const wantsInstructDerivation = (power_user.instruct.enabled && power_user.instruct.derived);
12401241 const wantsContextDerivation = power_user.context_derived;
1242+ const wantsContextSize = power_user.context_size_derived;
12411243 const supportsChatTemplate = [textgen_types.KOBOLDCPP, textgen_types.LLAMACPP].includes(textgen_settings.type);
12421244 if (supportsChatTemplate && (wantsInstructDerivation || wantsContextDerivation || wantsContextSize)) {
12431245 const response = await fetch('/api/backends/text-completions/props', {
12441246 method: 'POST',
12451247 headers: getRequestHeaders(),
@@ -1253,6 +1255,17 @@ async function getStatusTextgen() {
12531255 const data = await response.json();
12541256 if (data) {
12551257 const { chat_template, chat_template_hash } = data;
1258+ if (wantsContextSize && 'default_generation_settings' in data) {
1259+ const backend_max_context = data['default_generation_settings']['n_ctx'];
1260+ const old_value = max_context;
1261+ if (max_context !== backend_max_context) {
1262+ setGenerationParamsFromPreset({ max_length: backend_max_context });
1263+ }
1264+ if (old_value !== max_context) {
1265+ console.log(`Auto-switched max context from ${old_value} to ${max_context}`);
1266+ toastr.info(`${old_value} ⇒ ${max_context}`, 'Context Size Changed');
1267+ }
1268+ }
12561269 console.log(`We have chat template ${chat_template.split('\n')[0]}...`);
12571270 const templates = await deriveTemplatesFromChatTemplate(chat_template, chat_template_hash);
12581271 if (templates) {
@@ -6822,6 +6835,10 @@ export async function saveSettings(type) {
68226835 });
68236836}
68246837
6838+/**
6839+ * Sets the generation parameters from a preset object.
6840+ * @param {{ genamt?: number, max_length?: number }} preset Preset object
6841+ */
68256842export function setGenerationParamsFromPreset(preset) {
68266843 const needsUnlock = (preset.max_length ?? max_context) > MAX_CONTEXT_DEFAULT || (preset.genamt ?? amount_gen) > MAX_RESPONSE_DEFAULT;
68276844 $('#max_context_unlocked').prop('checked', needsUnlock).trigger('change');
public/scripts/extensions/expressions/settings.html+1 -1
@@ -40,7 +40,7 @@
4040 <div class="expression_fallback_block m-b-1 m-t-1">
4141 <label for="expression_fallback" data-i18n="Default / Fallback Expression">Default / Fallback Expression</label>
4242 <small data-i18n="Set the default and fallback expression being used when no matching expression is found.">Set the default and fallback expression being used when no matching expression is found.</small>
4343 <select id="expression_fallback" class="flex1 margin0" data-i18n="Fallback Expression" placeholder="Fallback Expression"></select>
4444 </div>
4545 <div class="expression_custom_block m-b-1 m-t-1">
4646 <label for="expression_custom" data-i18n="Custom Expressions">Custom Expressions</label>
public/scripts/extensions/tts/settings.html+2 -2
@@ -57,7 +57,7 @@
5757 </div>
5858 <div id="playback_rate_block" class="range-block">
5959 <hr>
6060 <div class="range-block-title justifyLeft" data-i18n="Audio Playback Speed">
6161 <small data-i18n="Audio Playback Speed">Audio Playback Speed</small>
6262 </div>
6363 <div class="range-block-range-and-counter">
@@ -80,4 +80,4 @@
8080 </div>
8181 </div>
8282 </div>
83-</div>
83 \ No newline at end of file
83+</div>
public/scripts/macros.js+20 -1
@@ -1,5 +1,5 @@
11import { Handlebars, moment, seedrandom, droll } from '../lib.js';
22import { chat, chat_metadata, main_api, getMaxContextSize, getCurrentChatId, substituteParams, eventSource, event_types } from '../script.js';
33import { timestampToMoment, isDigitsOnly, getStringHash, escapeRegex, uuidv4 } from './utils.js';
44import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
55import { getInstructMacros } from './instruct-mode.js';
@@ -521,3 +521,22 @@ export function evaluateMacros(content, env, postProcessFn) {
521521
522522 return content;
523523}
524+
525+export function initMacros() {
526+ function initLastGenerationType() {
527+ let lastGenerationType = '';
528+
529+ MacrosParser.registerMacro('lastGenerationType', () => lastGenerationType);
530+
531+ eventSource.on(event_types.GENERATION_STARTED, (type, _params, isDryRun) => {
532+ if (isDryRun) return;
533+ lastGenerationType = type || 'normal';
534+ });
535+
536+ eventSource.on(event_types.CHAT_CHANGED, () => {
537+ lastGenerationType = '';
538+ });
539+ }
540+
541+ initLastGenerationType();
542+}
public/scripts/power-user.js+12 -0
@@ -246,6 +246,7 @@ let power_user = {
246246 },
247247
248248 context_derived: false,
249+ context_size_derived: false,
249250
250251 sysprompt: {
251252 enabled: true,
@@ -1482,6 +1483,7 @@ async function loadPowerUserSettings(settings, data) {
14821483 $('#example_messages_behavior').val(getExampleMessagesBehavior());
14831484 $(`#example_messages_behavior option[value="${getExampleMessagesBehavior()}"]`).prop('selected', true);
14841485 $('#context_derived').parent().find('i').toggleClass('toggleEnabled', !!power_user.context_derived);
1486+ $('#context_size_derived').prop('checked', !!power_user.context_size_derived);
14851487
14861488 $('#console_log_prompts').prop('checked', power_user.console_log_prompts);
14871489 $('#request_token_probabilities').prop('checked', power_user.request_token_probabilities);
@@ -3079,6 +3081,16 @@ $(document).ready(() => {
30793081 $('#context_derived').parent().find('i').toggleClass('toggleEnabled', !!power_user.context_derived);
30803082 });
30813083
3084+ $('#context_size_derived').on('input', function () {
3085+ const value = !!$(this).prop('checked');
3086+ power_user.context_size_derived = value;
3087+ saveSettingsDebounced();
3088+ });
3089+
3090+ $('#context_size_derived').on('change', function () {
3091+ $('#context_size_derived').prop('checked', !!power_user.context_size_derived);
3092+ });
3093+
30823094 $('#always-force-name2-checkbox').change(function () {
30833095 power_user.always_force_name2 = !!$(this).prop('checked');
30843096 saveSettingsDebounced();
public/scripts/templates/macros.html+1 -0
@@ -8,6 +8,7 @@
88 <li><tt>&lcub;&lcub;noop&rcub;&rcub;</tt> – <span data-i18n="help_macros_4">no operation, just an empty string.</span></li>
99 <li><tt>&lcub;&lcub;original&rcub;&rcub;</tt> – <span data-i18n="help_macros_5">global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</span></li>
1010 <li><tt>&lcub;&lcub;input&rcub;&rcub;</tt> – <span data-i18n="help_macros_6">the user input</span></li>
11+ <li><tt>&lcub;&lcub;lastGenerationType&rcub;&rcub;</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>
1112 <li><tt>&lcub;&lcub;charPrompt&rcub;&rcub;</tt> – <span data-i18n="help_macros_7">the Character's Main Prompt override</span></li>
1213 <li><tt>&lcub;&lcub;charInstruction&rcub;&rcub;</tt> – <span data-i18n="help_macros_8">the Character's Post-History Instructions override</span></li>
1314 <li><tt>&lcub;&lcub;description&rcub;&rcub;</tt> – <span data-i18n="help_macros_9">the Character's Description</span></li>
src/endpoints/backends/text-completions.js+11 -11
@@ -152,7 +152,7 @@ router.post('/status', jsonParser, async function (request, response) {
152152
153153 if (!modelsReply.ok) {
154154 console.log('Models endpoint is offline.');
155155 return response.statussendStatus(400);
156156 }
157157
158158 /** @type {any} */
@@ -173,7 +173,7 @@ router.post('/status', jsonParser, async function (request, response) {
173173
174174 if (!Array.isArray(data.data)) {
175175 console.log('Models response is not an array.');
176176 return response.statussendStatus(400);
177177 }
178178
179179 const modelIds = data.data.map(x => x.id);
@@ -224,7 +224,7 @@ router.post('/status', jsonParser, async function (request, response) {
224224 return response.send({ result, data: data.data });
225225 } catch (error) {
226226 console.error(error);
227227 return response.statussendStatus(500);
228228 }
229229});
230230
@@ -244,7 +244,7 @@ router.post('/props', jsonParser, async function (request, response) {
244244 const propsReply = await fetch(propsUrl, args);
245245
246246 if (!propsReply.ok) {
247247 return response.statussendStatus(400);
248248 }
249249
250250 /** @type {any} */
@@ -258,7 +258,7 @@ router.post('/props', jsonParser, async function (request, response) {
258258 return response.send(props);
259259 } catch (error) {
260260 console.error(error);
261261 return response.statussendStatus(500);
262262 }
263263});
264264
@@ -450,7 +450,7 @@ ollama.post('/download', jsonParser, async function (request, response) {
450450 return response.send({ ok: true });
451451 } catch (error) {
452452 console.error(error);
453453 return response.statussendStatus(500);
454454 }
455455});
456456
@@ -493,7 +493,7 @@ ollama.post('/caption-image', jsonParser, async function (request, response) {
493493 return response.send({ caption });
494494 } catch (error) {
495495 console.error(error);
496496 return response.statussendStatus(500);
497497 }
498498});
499499
@@ -540,7 +540,7 @@ llamacpp.post('/caption-image', jsonParser, async function (request, response) {
540540
541541 } catch (error) {
542542 console.error(error);
543543 return response.statussendStatus(500);
544544 }
545545});
546546
@@ -569,7 +569,7 @@ llamacpp.post('/props', jsonParser, async function (request, response) {
569569
570570 } catch (error) {
571571 console.error(error);
572572 return response.statussendStatus(500);
573573 }
574574});
575575
@@ -619,7 +619,7 @@ llamacpp.post('/slots', jsonParser, async function (request, response) {
619619
620620 } catch (error) {
621621 console.error(error);
622622 return response.statussendStatus(500);
623623 }
624624});
625625
@@ -665,7 +665,7 @@ tabby.post('/download', jsonParser, async function (request, response) {
665665 return response.send({ ok: true });
666666 } catch (error) {
667667 console.error(error);
668668 return response.statussendStatus(500);
669669 }
670670});
671671
tests/package-lock.json+3 -3
@@ -2214,9 +2214,9 @@
22142214 }
22152215 },
22162216 "node_modules/cross-spawn": {
22172217 "version": "7.0.36",
22182218 "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.36.tgz",
22192219 "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6wuV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
22202220 "license": "MIT",
22212221 "dependencies": {
22222222 "path-key": "^3.1.0",