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 {
493493#mistralai_other_models:empty {
494494 display: none;
495495}
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 @@
16211621 </div>
16221622 <div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">
16231623 <hr class="width100p">
16241624 <h4div class="range-block-title justifyCentertitle_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>
16251629 <label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">
16261630 <input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />
16271631 <small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
16281632 </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>
16321635 <div class="textAlignCenter">
16331636 <small data-i18n="Global list">Global list</small>
16341637 </div>
@@ -1642,9 +1645,10 @@
16421645 <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>
16431646 </div>
16441647 </div>
1648+ </div>
16451649 <div class="range-block wide100p">
16461650 <div id="logit_bias_textgenerationwebui" class="range-block-title title_restorable">
16471651 <spanstrong data-i18n="Logit Bias">Logit Bias</spanstrong>
16481652 <div id="textgen_logit_bias_new_entry" class="menu_button menu_button_icon">
16491653 <i class="fa-xs fa-solid fa-plus"></i>
16501654 <small data-i18n="Add">Add</small>
public/scripts/preset-manager.js+1 -0
@@ -588,6 +588,7 @@ class PresetManager {
588588 'generic_model',
589589 'include_reasoning',
590590 'global_banned_tokens',
591+ 'send_banned_tokens',
591592 ];
592593 const settings = Object.assign({}, getSettingsByApiId(this.apiId));
593594
public/scripts/textgen-settings.js+4 -5
@@ -399,7 +399,7 @@ function getTokenizerForTokenIds() {
399399 * @returns {TokenBanResult} String with comma-separated banned token IDs
400400 */
401401function getCustomTokenBans() {
402402 if (!settings.send_banned_tokens || (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length)) {
403403 return {
404404 banned_tokens: '',
405405 banned_strings: [],
@@ -616,9 +616,8 @@ function sortAphroditeItemsByOrder(orderArray) {
616616}
617617
618618jQuery(function () {
619-
619+ $('#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');
622621 if (checked) {
623622 enableBannedStringsKillSwitch();
624623 } else {
@@ -966,7 +965,7 @@ function setSettingByName(setting, value, trigger) {
966965 $(`#${setting}_textgenerationwebui`).prop('checked', val);
967966
968967 if ('send_banned_tokens' === setting) {
969968 $('`#send_banned_tokens_textgenerationwebui'${setting}_textgenerationwebui`).trigger('change');
970969 }
971970 }
972971 else if (isText) {
public/style.css+1 -1
@@ -2876,7 +2876,7 @@ select option:not(:checked) {
28762876
28772877#instruct_enabled_label .menu_button:not(.toggleEnabled),
28782878#sysprompt_enabled_label .menu_button:not(.toggleEnabled),
28792879#bannedStringsKillSwitch_labelsend_banned_tokens_label .menu_button:not(.toggleEnabled) {
28802880 color: Red;
28812881}
28822882