From c5dad20fc41d8cf006df7e418eeb7a508dd815d8 Mon Sep 17 00:00:00 2001
From: RossAscends <124905043+RossAscends@users.noreply.github.com>
Date: Sun, 2 Feb 2025 12:00:01 +0900
Subject: [PATCH 1/8] add killswitch for banned strings
---
public/index.html | 21 +++++++++++++----
public/scripts/textgen-settings.js | 37 ++++++++++++++++++++++++++++++
public/style.css | 3 ++-
3 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/public/index.html b/public/index.html
index ee15ea62e..5d27a19b5 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1621,10 +1621,23 @@
-
- Banned Tokens/Strings
-
-
+
+
+
+
+
+
+
+
+ Banned Tokens/Strings
+
+
+
+
+
diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js
index 29bce0858..d79dee667 100644
--- a/public/scripts/textgen-settings.js
+++ b/public/scripts/textgen-settings.js
@@ -182,6 +182,7 @@ const settings = {
grammar_string: '',
json_schema: {},
banned_tokens: '',
+ sendBannedTokens: true,
sampler_priority: OOBA_DEFAULT_ORDER,
samplers: LLAMACPP_DEFAULT_ORDER,
samplers_priorities: APHRODITE_DEFAULT_ORDER,
@@ -274,6 +275,7 @@ export const setting_names = [
'grammar_string',
'json_schema',
'banned_tokens',
+ 'sendBannedTokens',
'ignore_eos_token',
'spaces_between_special_tokens',
'speculative_ngram',
@@ -452,6 +454,22 @@ function getCustomTokenBans() {
};
}
+async function enableBannedStringsKillSwitch() {
+ $('#bannedStringsKillSwitch_textgenerationwebui').prop('checked', true);
+ $('#bannedStringsKillSwitch_label').find('.menu_button').addClass('toggleEnabled').prop('title', 'Banned tokens/strings are being sent into the request.');
+ settings.sendBannedTokens = true;
+ saveSettingsDebounced();
+ return '';
+}
+
+async function disableBannedStringsKillSwitch() {
+ $('#bannedStringsKillSwitch_textgenerationwebui').prop('checked', false);
+ $('#bannedStringsKillSwitch_label').find('.menu_button').removeClass('toggleEnabled').prop('title', 'Banned tokens/strings are NOT being sent into the request.');
+ settings.sendBannedTokens = false;
+ saveSettingsDebounced();
+ return '';
+}
+
/**
* Calculates logit bias object from the logit bias list.
* @returns {object} Logit bias object
@@ -594,6 +612,16 @@ function sortAphroditeItemsByOrder(orderArray) {
}
jQuery(function () {
+
+ $('#bannedStringsKillSwitch_textgenerationwebui').on('change', function () {
+ const checked = $(this).prop('checked');
+ if (checked) {
+ enableBannedStringsKillSwitch();
+ } else {
+ disableBannedStringsKillSwitch();
+ }
+ });
+
$('#koboldcpp_order').sortable({
delay: getSortableDelay(),
stop: function () {
@@ -927,6 +955,11 @@ function setSettingByName(setting, value, trigger) {
return;
}
+ if ('sendBannedTokens' === setting) {
+ $('#bannedStringsKillSwitch_textgenerationwebui').prop('checked', value).trigger('change');
+ return;
+ }
+
const isCheckbox = $(`#${setting}_textgenerationwebui`).attr('type') == 'checkbox';
const isText = $(`#${setting}_textgenerationwebui`).attr('type') == 'text' || $(`#${setting}_textgenerationwebui`).is('textarea');
if (isCheckbox) {
@@ -1461,5 +1494,9 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
}
}
+ //last check before sending sampler params, strip banned strings if toggled off.
+ const sendBannedStrings = $('#bannedStringsKillSwitch_textgenerationwebui').prop('checked');
+ if (!sendBannedStrings) { delete params.banned_strings; }
+
return params;
}
diff --git a/public/style.css b/public/style.css
index fc2a4728a..cf0ea18af 100644
--- a/public/style.css
+++ b/public/style.css
@@ -2816,7 +2816,8 @@ select option:not(:checked) {
}
#instruct_enabled_label .menu_button:not(.toggleEnabled),
-#sysprompt_enabled_label .menu_button:not(.toggleEnabled) {
+#sysprompt_enabled_label .menu_button:not(.toggleEnabled),
+#bannedStringsKillSwitch_label .menu_button:not(.toggleEnabled) {
color: Red;
}
From 412d638e9e7335b9e1416cf512c3af5bb6469959 Mon Sep 17 00:00:00 2001
From: Cohee <18619528+Cohee1207@users.noreply.github.com>
Date: Thu, 13 Feb 2025 22:07:36 +0200
Subject: [PATCH 2/8] Text Completion: Add global banned strings list
---
public/index.html | 9 +++++++++
public/scripts/preset-manager.js | 1 +
public/scripts/textgen-settings.js | 7 +++++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/public/index.html b/public/index.html
index d46dab4fd..c276f29e4 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1625,6 +1625,15 @@
Banned Tokens/Strings
+
+ Global list
+
+
+
+
+
+ Preset-specific list
+
diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js
index 0d7d3c133..4a21efa9e 100644
--- a/public/scripts/preset-manager.js
+++ b/public/scripts/preset-manager.js
@@ -587,6 +587,7 @@ class PresetManager {
'derived',
'generic_model',
'include_reasoning',
+ 'global_banned_tokens',
];
const settings = Object.assign({}, getSettingsByApiId(this.apiId));
diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js
index 50c630841..392e33546 100644
--- a/public/scripts/textgen-settings.js
+++ b/public/scripts/textgen-settings.js
@@ -182,6 +182,7 @@ const settings = {
grammar_string: '',
json_schema: {},
banned_tokens: '',
+ global_banned_tokens: '',
sampler_priority: OOBA_DEFAULT_ORDER,
samplers: LLAMACPP_DEFAULT_ORDER,
samplers_priorities: APHRODITE_DEFAULT_ORDER,
@@ -274,6 +275,7 @@ export const setting_names = [
'grammar_string',
'json_schema',
'banned_tokens',
+ 'global_banned_tokens',
'ignore_eos_token',
'spaces_between_special_tokens',
'speculative_ngram',
@@ -404,8 +406,9 @@ function getCustomTokenBans() {
const tokenizer = getTokenizerForTokenIds();
const banned_tokens = [];
const banned_strings = [];
- const sequences = settings.banned_tokens
- .split('\n')
+ const sequences = []
+ .concat(settings.banned_tokens.split('\n'))
+ .concat(settings.global_banned_tokens.split('\n'))
.concat(textgenerationwebui_banned_in_macros)
.filter(x => x.length > 0)
.filter(onlyUnique);
From 8a4cf86b6560106026f28ba6ba0f8ca8d07ba306 Mon Sep 17 00:00:00 2001
From: Cohee <18619528+Cohee1207@users.noreply.github.com>
Date: Sat, 15 Feb 2025 00:28:38 +0200
Subject: [PATCH 3/8] Integrate killswitch into the block
---
public/css/toggle-dependent.css | 4 ++++
public/index.html | 34 +++++++++++++++++-------------
public/scripts/preset-manager.js | 1 +
public/scripts/textgen-settings.js | 9 ++++----
public/style.css | 2 +-
5 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/public/css/toggle-dependent.css b/public/css/toggle-dependent.css
index 967aa55e6..59c2e9a28 100644
--- a/public/css/toggle-dependent.css
+++ b/public/css/toggle-dependent.css
@@ -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);
+}
diff --git a/public/index.html b/public/index.html
index d1a6db538..54a9c143f 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1621,30 +1621,34 @@