Integrate killswitch into the block

This commit is contained in:
Cohee
2025-02-15 00:28:38 +02:00
parent a2a15b9978
commit 8a4cf86b65
5 changed files with 29 additions and 21 deletions

View File

@ -493,3 +493,7 @@ label[for="trim_spaces"]:not(:has(input:checked)) small {
#mistralai_other_models:empty {
display: none;
}
#banned_tokens_block_ooba:not(:has(#send_banned_tokens_textgenerationwebui:checked)) #banned_tokens_controls_ooba {
filter: brightness(0.5);
}

View File

@ -1621,14 +1621,17 @@
</div>
<div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">
<hr class="width100p">
<h4 class="range-block-title justifyCenter">
<div class="range-block-title title_restorable">
<div>
<strong data-i18n="Banned Tokens">Banned Tokens/Strings</strong>
<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>
</div>
<label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">
<input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />
<small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
</label>
<span data-i18n="Banned Tokens">Banned Tokens/Strings</span>
<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>
</h4>
</div>
<div id="banned_tokens_controls_ooba">
<div class="textAlignCenter">
<small data-i18n="Global list">Global list</small>
</div>
@ -1642,9 +1645,10 @@
<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>
</div>
</div>
</div>
<div class="range-block wide100p">
<div id="logit_bias_textgenerationwebui" class="range-block-title title_restorable">
<span data-i18n="Logit Bias">Logit Bias</span>
<strong data-i18n="Logit Bias">Logit Bias</strong>
<div id="textgen_logit_bias_new_entry" class="menu_button menu_button_icon">
<i class="fa-xs fa-solid fa-plus"></i>
<small data-i18n="Add">Add</small>

View File

@ -588,6 +588,7 @@ class PresetManager {
'generic_model',
'include_reasoning',
'global_banned_tokens',
'send_banned_tokens',
];
const settings = Object.assign({}, getSettingsByApiId(this.apiId));

View File

@ -399,7 +399,7 @@ function getTokenizerForTokenIds() {
* @returns {TokenBanResult} String with comma-separated banned token IDs
*/
function getCustomTokenBans() {
if (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length) {
if (!settings.send_banned_tokens || (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length)) {
return {
banned_tokens: '',
banned_strings: [],
@ -616,9 +616,8 @@ function sortAphroditeItemsByOrder(orderArray) {
}
jQuery(function () {
$('#bannedStringsKillSwitch_textgenerationwebui').on('change', function () {
const checked = $(this).prop('checked');
$('#send_banned_tokens_textgenerationwebui').on('change', function () {
const checked = !!$(this).prop('checked');
if (checked) {
enableBannedStringsKillSwitch();
} else {
@ -966,7 +965,7 @@ function setSettingByName(setting, value, trigger) {
$(`#${setting}_textgenerationwebui`).prop('checked', val);
if ('send_banned_tokens' === setting) {
$('#send_banned_tokens_textgenerationwebui').trigger('change');
$(`#${setting}_textgenerationwebui`).trigger('change');
}
}
else if (isText) {

View File

@ -2876,7 +2876,7 @@ select option:not(:checked) {
#instruct_enabled_label .menu_button:not(.toggleEnabled),
#sysprompt_enabled_label .menu_button:not(.toggleEnabled),
#bannedStringsKillSwitch_label .menu_button:not(.toggleEnabled) {
#send_banned_tokens_label .menu_button:not(.toggleEnabled) {
color: Red;
}