From 52ecad1cdf5940cc0f31a8065fab9df2c92e08be Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 27 Oct 2023 21:02:03 +0300 Subject: [PATCH] Rework single-line mode, add section for Context Formatting settings --- default/settings.json | 1 - public/context/Adventure.json | 3 +- public/css/st-tailwind.css | 4 + public/index.html | 144 ++++++++++++++++++--------------- public/script.js | 4 + public/scripts/kai-settings.js | 14 +--- public/scripts/power-user.js | 27 ++++--- 7 files changed, 107 insertions(+), 90 deletions(-) diff --git a/default/settings.json b/default/settings.json index 6a181a144..e81817719 100644 --- a/default/settings.json +++ b/default/settings.json @@ -405,7 +405,6 @@ "typical": 1, "tfs": 1, "rep_pen_slope": 0, - "single_line": false, "streaming_kobold": false, "sampler_order": [ 6, diff --git a/public/context/Adventure.json b/public/context/Adventure.json index 9b90cba54..44ae59cc1 100644 --- a/public/context/Adventure.json +++ b/public/context/Adventure.json @@ -5,7 +5,6 @@ "always_force_name2": false, "trim_sentences": false, "include_newline": false, - "custom_stopping_strings": "[\"\\n\"]", - "custom_stopping_strings_macro": true, + "single_line": true, "name": "Adventure" } \ No newline at end of file diff --git a/public/css/st-tailwind.css b/public/css/st-tailwind.css index dca40662a..fb8a537e5 100644 --- a/public/css/st-tailwind.css +++ b/public/css/st-tailwind.css @@ -105,6 +105,10 @@ align-items: flex-end !important; } +.alignItemsBaseline { + align-items: baseline !important; +} + .alignSelfStart { align-self: start; } diff --git a/public/index.html b/public/index.html index 985dd0451..6b8b5ee4c 100644 --- a/public/index.html +++ b/public/index.html @@ -997,17 +997,6 @@ -
- -
- - Generate only one line per request (KoboldAI only, ignored by KoboldCpp). - -
-
-

Advanced Formatting +

+ Advanced Formatting ? @@ -2470,6 +2460,52 @@

+
+
+

+ Context Formatting +

+ +  (Saved to Context Template) + +
+ + + + + +
+

+ Misc. Settings +

+ +

Tokenizer @@ -2496,77 +2532,57 @@

- - - - - - -
-

- - Start Reply With - -

+
- +

+ + Start Reply With + +

+
+ +
+
-
-

- Non-markdown strings +

+ + Non-markdown strings +

-

-

- JSON serialized array of strings, for example:
- ["\n", "\nUser:", "\nChar:"] + JSON serialized array of strings
- -
- +
+ +
+
-

diff --git a/public/script.js b/public/script.js index 787d4d9dd..fcd1a843f 100644 --- a/public/script.js +++ b/public/script.js @@ -1840,6 +1840,10 @@ function getStoppingStrings(isImpersonate) { result.push(...customStoppingStrings); } + if (power_user.single_line) { + result.unshift('\n'); + } + return result.filter(onlyUnique); } diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index 29d63e729..f7c808308 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -20,7 +20,6 @@ export const kai_settings = { typical: 1, tfs: 1, rep_pen_slope: 0.9, - single_line: false, streaming_kobold: false, sampler_order: [0, 1, 2, 3, 4, 5, 6], mirostat: 0, @@ -76,11 +75,6 @@ export function loadKoboldSettings(preset) { $(slider.counterId).val(formattedValue); } - // TODO: refactor checkboxes (if adding any more) - if (preset.hasOwnProperty('single_line')) { - kai_settings.single_line = preset.single_line; - $('#single_line').prop('checked', kai_settings.single_line); - } if (preset.hasOwnProperty('streaming_kobold')) { kai_settings.streaming_kobold = preset.streaming_kobold; $('#streaming_kobold').prop('checked', kai_settings.streaming_kobold); @@ -128,7 +122,7 @@ export function getKoboldGenerationData(finalPrompt, settings, maxLength, maxCon s6: sampler_order[5], s7: sampler_order[6], use_world_info: false, - singleline: kai_settings.single_line, + singleline: false, stop_sequence: (kai_flags.can_use_stop_sequence || isHorde) ? getStoppingStrings(isImpersonate) : undefined, streaming: kai_settings.streaming_kobold && kai_flags.can_use_streaming && type !== 'quiet', can_abort: kai_flags.can_use_streaming, @@ -389,12 +383,6 @@ jQuery(function () { }); }); - $('#single_line').on("input", function () { - const value = !!$(this).prop('checked'); - kai_settings.single_line = value; - saveSettingsDebounced(); - }); - $('#streaming_kobold').on("input", function () { const value = !!$(this).prop('checked'); kai_settings.streaming_kobold = value; diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index b197d59a0..3dc83c8cf 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -170,6 +170,7 @@ let power_user = { relaxed_api_urls: false, world_import_dialog: true, disable_group_trimming: false, + single_line: false, default_instruct: '', instruct: { @@ -259,11 +260,10 @@ const contextControls = [ { id: "context_chat_start", property: "chat_start", isCheckbox: false, isGlobalSetting: false }, // Existing power user settings - { id: "always-force-name2-checkbox", property: "always_force_name2", isCheckbox: true, isGlobalSetting: true }, - { id: "trim_sentences_checkbox", property: "trim_sentences", isCheckbox: true, isGlobalSetting: true }, - { id: "include_newline_checkbox", property: "include_newline", isCheckbox: true, isGlobalSetting: true }, - { id: "custom_stopping_strings", property: "custom_stopping_strings", isCheckbox: false, isGlobalSetting: true }, - { id: "custom_stopping_strings_macro", property: "custom_stopping_strings_macro", isCheckbox: true, isGlobalSetting: true } + { id: "always-force-name2-checkbox", property: "always_force_name2", isCheckbox: true, isGlobalSetting: true, defaultValue: true }, + { id: "trim_sentences_checkbox", property: "trim_sentences", isCheckbox: true, isGlobalSetting: true, defaultValue: false }, + { id: "include_newline_checkbox", property: "include_newline", isCheckbox: true, isGlobalSetting: true, defaultValue: false }, + { id: "single_line", property: "single_line", isCheckbox: true, isGlobalSetting: true, defaultValue: false }, ]; let browser_has_focus = true; @@ -924,6 +924,7 @@ function loadPowerUserSettings(settings, data) { power_user.tokenizer = tokenizers.GPT2; } + $('#single_line').prop("checked", power_user.single_line); $('#relaxed_api_urls').prop("checked", power_user.relaxed_api_urls); $('#world_import_dialog').prop("checked", power_user.world_import_dialog); $('#trim_spaces').prop("checked", power_user.trim_spaces); @@ -1173,11 +1174,13 @@ function loadContextSettings() { power_user.context.preset = name; contextControls.forEach(control => { - if (preset[control.property] !== undefined) { + const presetValue = preset[control.property] ?? control.defaultValue; + + if (presetValue !== undefined) { if (control.isGlobalSetting) { - power_user[control.property] = preset[control.property]; + power_user[control.property] = presetValue; } else { - power_user.context[control.property] = preset[control.property]; + power_user.context[control.property] = presetValue; } const $element = $(`#${control.id}`); @@ -1938,6 +1941,12 @@ $(document).ready(() => { saveSettingsDebounced(); }); + $('#single_line').on("input", function () { + const value = !!$(this).prop('checked'); + power_user.single_line = value; + saveSettingsDebounced(); + }); + $("#always-force-name2-checkbox").change(function () { power_user.always_force_name2 = !!$(this).prop("checked"); saveSettingsDebounced(); @@ -2115,7 +2124,6 @@ $(document).ready(() => { saveSettingsDebounced(); }); - $("#user-mes-blur-tint-color-picker").on('change', (evt) => { power_user.user_mes_blur_tint_color = evt.detail.rgba; applyThemeColor('userMesBlurTint'); @@ -2153,7 +2161,6 @@ $(document).ready(() => { power_user.movingUIPreset = movingUIPresetSelected; applyMovingUIPreset(movingUIPresetSelected); saveSettingsDebounced(); - }); $("#ui-preset-save-button").on('click', saveTheme);