Integrate killswitch into the block

8a4cf86b6560106026f28ba6ba0f8ca8d07ba306

Cohee <18619528+Cohee1207@users.noreply.github.com>

5 files changed, +19 -11Showing whitespace changes
public/css/toggle-dependent.css+4 -0
@@ -493,3 +493,7 @@ label[for="trim_spaces"]:not(:has(input:checked)) small {
493#mistralai_other_models:empty {493#mistralai_other_models:empty {
494 display: none;494 display: none;
495}495}
496
497#banned_tokens_block_ooba:not(:has(#send_banned_tokens_textgenerationwebui:checked)) #banned_tokens_controls_ooba {
498 filter: brightness(0.5);
499}
public/index.html+9 -5
@@ -1621,14 +1621,17 @@
1621 </div>1621 </div>
1622 <div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">1622 <div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">
1623 <hr class="width100p">1623 <hr class="width100p">
1624 <h4 class="range-block-title justifyCenter">1624 <div class="range-block-title title_restorable">
1625 <div>
1626 <strong data-i18n="Banned Tokens">Banned Tokens/Strings</strong>
1627 <div class="margin5 fa-solid fa-circle-info opacity50p " data-i18n="[title]LLaMA / Mistral / Yi models only" title="Enter sequences you don't want to appear in the output.&#13;Unquoted text will be tokenized in the back end and banned as tokens.&#13;[token ids] will be banned as-is.&#13;Most tokens have a leading space. Use token counter (with the correct tokenizer selected first!) if you are unsure.&#13;Enclose text in double quotes to ban the entire string as a set.&#13;Quoted Strings and [Token ids] must be on their own line."></div>
1628 </div>
1625 <label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">1629 <label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">
1626 <input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />1630 <input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />
1627 <small><i class="fa-solid fa-power-off menu_button margin0"></i></small>1631 <small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
1628 </label>1632 </label>
1629 <span data-i18n="Banned Tokens">Banned Tokens/Strings</span>1633 </div>
1630 <div class="margin5 fa-solid fa-circle-info opacity50p " data-i18n="[title]LLaMA / Mistral / Yi models only" title="Enter sequences you don't want to appear in the output.&#13;Unquoted text will be tokenized in the back end and banned as tokens.&#13;[token ids] will be banned as-is.&#13;Most tokens have a leading space. Use token counter (with the correct tokenizer selected first!) if you are unsure.&#13;Enclose text in double quotes to ban the entire string as a set.&#13;Quoted Strings and [Token ids] must be on their own line."></div>1634 <div id="banned_tokens_controls_ooba">
1631 </h4>
1632 <div class="textAlignCenter">1635 <div class="textAlignCenter">
1633 <small data-i18n="Global list">Global list</small>1636 <small data-i18n="Global list">Global list</small>
1634 </div>1637 </div>
@@ -1642,9 +1645,10 @@
1642 <textarea id="banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens&#10;[420, 69, 1337]&#10;"Some verbatim string"'></textarea>1645 <textarea id="banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens&#10;[420, 69, 1337]&#10;"Some verbatim string"'></textarea>
1643 </div>1646 </div>
1644 </div>1647 </div>
1648 </div>
1645 <div class="range-block wide100p">1649 <div class="range-block wide100p">
1646 <div id="logit_bias_textgenerationwebui" class="range-block-title title_restorable">1650 <div id="logit_bias_textgenerationwebui" class="range-block-title title_restorable">
1647 <span data-i18n="Logit Bias">Logit Bias</span>1651 <strong data-i18n="Logit Bias">Logit Bias</strong>
1648 <div id="textgen_logit_bias_new_entry" class="menu_button menu_button_icon">1652 <div id="textgen_logit_bias_new_entry" class="menu_button menu_button_icon">
1649 <i class="fa-xs fa-solid fa-plus"></i>1653 <i class="fa-xs fa-solid fa-plus"></i>
1650 <small data-i18n="Add">Add</small>1654 <small data-i18n="Add">Add</small>
public/scripts/preset-manager.js+1 -0
@@ -588,6 +588,7 @@ class PresetManager {
588 'generic_model',588 'generic_model',
589 'include_reasoning',589 'include_reasoning',
590 'global_banned_tokens',590 'global_banned_tokens',
591 'send_banned_tokens',
591 ];592 ];
592 const settings = Object.assign({}, getSettingsByApiId(this.apiId));593 const settings = Object.assign({}, getSettingsByApiId(this.apiId));
593594
public/scripts/textgen-settings.js+4 -5
@@ -399,7 +399,7 @@ function getTokenizerForTokenIds() {
399 * @returns {TokenBanResult} String with comma-separated banned token IDs399 * @returns {TokenBanResult} String with comma-separated banned token IDs
400 */400 */
401function getCustomTokenBans() {401function getCustomTokenBans() {
402 if (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length) {402 if (!settings.send_banned_tokens || (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length)) {
403 return {403 return {
404 banned_tokens: '',404 banned_tokens: '',
405 banned_strings: [],405 banned_strings: [],
@@ -616,9 +616,8 @@ function sortAphroditeItemsByOrder(orderArray) {
616}616}
617617
618jQuery(function () {618jQuery(function () {
619619 $('#send_banned_tokens_textgenerationwebui').on('change', function () {
620 $('#bannedStringsKillSwitch_textgenerationwebui').on('change', function () {620 const checked = !!$(this).prop('checked');
621 const checked = $(this).prop('checked');
622 if (checked) {621 if (checked) {
623 enableBannedStringsKillSwitch();622 enableBannedStringsKillSwitch();
624 } else {623 } else {
@@ -966,7 +965,7 @@ function setSettingByName(setting, value, trigger) {
966 $(`#${setting}_textgenerationwebui`).prop('checked', val);965 $(`#${setting}_textgenerationwebui`).prop('checked', val);
967966
968 if ('send_banned_tokens' === setting) {967 if ('send_banned_tokens' === setting) {
969 $('#send_banned_tokens_textgenerationwebui').trigger('change');968 $(`#${setting}_textgenerationwebui`).trigger('change');
970 }969 }
971 }970 }
972 else if (isText) {971 else if (isText) {
public/style.css+1 -1
@@ -2876,7 +2876,7 @@ select option:not(:checked) {
28762876
2877#instruct_enabled_label .menu_button:not(.toggleEnabled),2877#instruct_enabled_label .menu_button:not(.toggleEnabled),
2878#sysprompt_enabled_label .menu_button:not(.toggleEnabled),2878#sysprompt_enabled_label .menu_button:not(.toggleEnabled),
2879#bannedStringsKillSwitch_label .menu_button:not(.toggleEnabled) {2879#send_banned_tokens_label .menu_button:not(.toggleEnabled) {
2880 color: Red;2880 color: Red;
2881}2881}
28822882