diff --git a/public/index.html b/public/index.html
index 79adc1b4b..cad011ad1 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1915,6 +1915,20 @@
Show reply prefix in chat
+
+
+ Custom Stopping Strings (KoboldAI/TextGen)
+
+
+
+ JSON serialized array of strings, for example:
+ ["\n", "\nUser:", "\nChar:"]
+
+
+
+
+
+
Pygmalion Formatting
diff --git a/public/script.js b/public/script.js
index a4fe06cb7..1bcc779f8 100644
--- a/public/script.js
+++ b/public/script.js
@@ -74,6 +74,7 @@ import {
formatInstructModePrompt,
persona_description_positions,
loadMovingUIState,
+ getCustomStoppingStrings,
} from "./scripts/power-user.js";
import {
@@ -1624,6 +1625,11 @@ function getStoppingStrings(isImpersonate, addSpace) {
}
}
+ if (power_user.custom_stopping_strings) {
+ const customStoppingStrings = getCustomStoppingStrings();
+ result.push(...customStoppingStrings);
+ }
+
return addSpace ? result.map(x => `${x} `) : result;
}
diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js
index 07bd3a747..f7dad23e5 100644
--- a/public/scripts/power-user.js
+++ b/public/scripts/power-user.js
@@ -186,6 +186,8 @@ let power_user = {
persona_description: '',
persona_description_position: persona_description_positions.BEFORE_CHAR,
+
+ custom_stopping_strings: '',
};
let themes = [];
@@ -651,6 +653,7 @@ function loadPowerUserSettings(settings, data) {
$('#auto_swipe_minimum_length').val(power_user.auto_swipe_minimum_length);
$('#auto_swipe_blacklist').val(power_user.auto_swipe_blacklist.join(", "));
$('#auto_swipe_blacklist_threshold').val(power_user.auto_swipe_blacklist_threshold);
+ $('#custom_stopping_strings').val(power_user.custom_stopping_strings);
$("#console_log_prompts").prop("checked", power_user.console_log_prompts);
$('#auto_fix_generated_markdown').prop("checked", power_user.auto_fix_generated_markdown);
@@ -1381,6 +1384,25 @@ function setAvgBG() {
}
+export function getCustomStoppingStrings() {
+ try {
+ // Parse the JSON string
+ const strings = JSON.parse(power_user.custom_stopping_strings);
+
+ // Make sure it's an array
+ if (!Array.isArray(strings)) {
+ return [];
+ }
+
+ // Make sure all the elements are strings
+ return strings.filter((s) => typeof s === 'string');
+ } catch (error) {
+ // If there's an error, return an empty array
+ console.warn('Error parsing custom stopping strings:', error);
+ return [];
+ }
+}
+
$(document).ready(() => {
$(window).on('resize', async () => {
@@ -1832,6 +1854,11 @@ $(document).ready(() => {
$(this).toggleClass('fa-eye fa-eye-slash');
});
+ $('#custom_stopping_strings').on('input', function () {
+ power_user.custom_stopping_strings = $(this).val();
+ saveSettingsDebounced();
+ });
+
$(window).on('focus', function () {
browser_has_focus = true;
});