diff --git a/public/TextGen Settings/Beam Search.settings b/public/TextGen Settings/Beam Search.settings new file mode 100644 index 000000000..b2959db64 --- /dev/null +++ b/public/TextGen Settings/Beam Search.settings @@ -0,0 +1,15 @@ +{ + temp: 0.7, + top_p: 0.92, + top_k: 150, + typical_p: 1, + rep_pen: 4.5, + no_repeat_ngram_size: 2, + penalty_alpha: 0, + num_beams: 10, + length_penalty: 1.4, + min_length: 200, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: true +} \ No newline at end of file diff --git a/public/TextGen Settings/Contrastive Search.settings b/public/TextGen Settings/Contrastive Search.settings new file mode 100644 index 000000000..079036963 --- /dev/null +++ b/public/TextGen Settings/Contrastive Search.settings @@ -0,0 +1,15 @@ +{ + temp: 1, + top_p: 1, + top_k: 4, + typical_p: 1, + rep_pen: 1, + no_repeat_ngram_size: 0, + penalty_alpha: 0.6, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: false, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/Default.settings b/public/TextGen Settings/Default.settings new file mode 100644 index 000000000..8f0e0fb81 --- /dev/null +++ b/public/TextGen Settings/Default.settings @@ -0,0 +1,15 @@ +{ + temp: 0.7, + top_p: 0.5, + top_k: 40, + typical_p: 1, + rep_pen: 1.2, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/Deterministic.settings b/public/TextGen Settings/Deterministic.settings new file mode 100644 index 000000000..06159f378 --- /dev/null +++ b/public/TextGen Settings/Deterministic.settings @@ -0,0 +1,15 @@ +{ + temp: 1, + top_p: 1, + top_k: 50, + typical_p: 1, + rep_pen: 1, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: false, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/Kobold (Godlike).settings b/public/TextGen Settings/Kobold (Godlike).settings new file mode 100644 index 000000000..3238806f2 --- /dev/null +++ b/public/TextGen Settings/Kobold (Godlike).settings @@ -0,0 +1,15 @@ +{ + temp: 0.7, + top_p: 0.5, + top_k: 0, + typical_p: 0.19, + rep_pen: 1.1, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/Kobold (Liminal Drift).settings b/public/TextGen Settings/Kobold (Liminal Drift).settings new file mode 100644 index 000000000..ed0f279f8 --- /dev/null +++ b/public/TextGen Settings/Kobold (Liminal Drift).settings @@ -0,0 +1,15 @@ +{ + temp: 0.66, + top_p: 1, + top_k: 0, + typical_p: 0.6, + rep_pen: 1.1, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/Naive.settings b/public/TextGen Settings/Naive.settings new file mode 100644 index 000000000..61b51a17b --- /dev/null +++ b/public/TextGen Settings/Naive.settings @@ -0,0 +1,15 @@ +{ + temp: 0.7, + top_p: 0.85, + top_k: 50, + typical_p: 1, + rep_pen: 1, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Best Guess).settings b/public/TextGen Settings/NovelAI (Best Guess).settings new file mode 100644 index 000000000..ea5914df0 --- /dev/null +++ b/public/TextGen Settings/NovelAI (Best Guess).settings @@ -0,0 +1,15 @@ +{ + temp: 0.8, + top_p: 0.9, + top_k: 100, + typical_p: 1, + rep_pen: 1.15, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Decadence).settings b/public/TextGen Settings/NovelAI (Decadence).settings new file mode 100644 index 000000000..8f88bf644 --- /dev/null +++ b/public/TextGen Settings/NovelAI (Decadence).settings @@ -0,0 +1,15 @@ +{ + temp: 1.99, + top_p: 1, + top_k: 100, + typical_p: 0.97, + rep_pen: 1, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Genesis).settings b/public/TextGen Settings/NovelAI (Genesis).settings new file mode 100644 index 000000000..d33c8be2f --- /dev/null +++ b/public/TextGen Settings/NovelAI (Genesis).settings @@ -0,0 +1,15 @@ +{ + temp: 0.63, + top_p: 0.98, + top_k: 0, + typical_p: 1, + rep_pen: 1.05, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Lycaenidae).settings b/public/TextGen Settings/NovelAI (Lycaenidae).settings new file mode 100644 index 000000000..80658de6e --- /dev/null +++ b/public/TextGen Settings/NovelAI (Lycaenidae).settings @@ -0,0 +1,15 @@ +{ + temp: 1.99, + top_p: 0.85, + top_k: 12, + typical_p: 1, + rep_pen: 1.15, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Ouroboros).settings b/public/TextGen Settings/NovelAI (Ouroboros).settings new file mode 100644 index 000000000..9ba5b6c96 --- /dev/null +++ b/public/TextGen Settings/NovelAI (Ouroboros).settings @@ -0,0 +1,15 @@ +{ + temp: 1.07, + top_p: 1, + top_k: 100, + typical_p: 1, + rep_pen: 1.05, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Pleasing Results).settings b/public/TextGen Settings/NovelAI (Pleasing Results).settings new file mode 100644 index 000000000..1f292bfeb --- /dev/null +++ b/public/TextGen Settings/NovelAI (Pleasing Results).settings @@ -0,0 +1,15 @@ +{ + temp: 0.44, + top_p: 1, + top_k: 0, + typical_p: 1, + rep_pen: 1.15, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Sphinx Moth).settings b/public/TextGen Settings/NovelAI (Sphinx Moth).settings new file mode 100644 index 000000000..4db55a092 --- /dev/null +++ b/public/TextGen Settings/NovelAI (Sphinx Moth).settings @@ -0,0 +1,15 @@ +{ + temp: 1.99, + top_p: 0.18, + top_k: 30, + typical_p: 1, + rep_pen: 1.15, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/NovelAI (Storywriter).settings b/public/TextGen Settings/NovelAI (Storywriter).settings new file mode 100644 index 000000000..4ea533eb9 --- /dev/null +++ b/public/TextGen Settings/NovelAI (Storywriter).settings @@ -0,0 +1,15 @@ +{ + temp: 0.72, + top_p: 0.73, + top_k: 0, + typical_p: 1, + rep_pen: 1.1, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/TextGen Settings/Pygmalion.settings b/public/TextGen Settings/Pygmalion.settings new file mode 100644 index 000000000..44e924228 --- /dev/null +++ b/public/TextGen Settings/Pygmalion.settings @@ -0,0 +1,15 @@ +{ + temp: 0.5, + top_p: 0.9, + top_k: 0, + typical_p: 1, + rep_pen: 1.1, + no_repeat_ngram_size: 0, + penalty_alpha: 0, + num_beams: 1, + length_penalty: 1, + min_length: 0, + encoder_rep_pen: 1, + do_sample: true, + early_stopping: false +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index 1db0d359f..0c0a68ef5 100644 --- a/public/index.html +++ b/public/index.html @@ -264,7 +264,6 @@

Text generation web UI presets

diff --git a/public/script.js b/public/script.js index d045982fc..b3fc5a4de 100644 --- a/public/script.js +++ b/public/script.js @@ -2047,8 +2047,6 @@ async function getSettings(type) { //Load AI model config settings (temp, context length, anchors, and anchor order) - loadTextGenSettings(settings.textgenerationwebui_settings); - amount_gen = settings.amount_gen; if (settings.max_context !== undefined) max_context = parseInt(settings.max_context); @@ -2079,11 +2077,15 @@ async function getSettings(type) { //console.log('getsettings calling showswipebtns'); showSwipeButtons(); + // Kobold loadKoboldSettings(settings); - //Novel + // Novel loadNovelSettings(settings); + // TextGen + loadTextGenSettings(settings); + // OpenAI loadOpenAISettings(data, settings); diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index a52f18bb4..165423378 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -22,8 +22,12 @@ let textgenerationwebui_settings = { do_sample: true, early_stopping: false, seed: -1, + preset: 'Default', }; +let textgenerationwebui_presets = []; +let textgenerationwebui_preset_names = []; + const setting_names = [ "temp", "rep_pen", @@ -41,26 +45,40 @@ const setting_names = [ "seed", ]; -function loadTextGenSettings(settings) { - if (settings) { - Object.assign(textgenerationwebui_settings, settings); +function selectPreset(name) { + const preset = textgenerationwebui_presets[name]; + + if (!preset) { + return; } - for (const i of setting_names) { - const isCheckbox = $(`#${i}_textgenerationwebui`).attr('type') == 'checkbox'; - if (isCheckbox) { - const val = Boolean(textgenerationwebui_settings[i]); - $(`#${i}_textgenerationwebui`).prop('checked', val); - } - else { - const val = parseFloat(textgenerationwebui_settings[i]); - $(`#${i}_textgenerationwebui`).val(val); - $(`#${i}_counter_textgenerationwebui`).text(val.toFixed(2)); - } + for (const name of setting_names) { + const value = preset[name]; + setSettingByName(name, value); } } -$(document).ready(function() { +function loadTextGenSettings(settings) { + textgenerationwebui_presets = settings.textgenerationwebui_presets ?? []; + textgenerationwebui_preset_names = settings.textgenerationwebui_preset_names ?? []; + Object.assign(textgenerationwebui_settings, settings.textgenerationwebui_settings ?? {}); + + if (textgenerationwebui_settings.preset) { + $('#settings_preset_textgenerationwebui').val(textgenerationwebui_settings.preset); + } + + for (const i of setting_names) { + const value = textgenerationwebui_settings[i]; + setSettingByName(i, value); + } +} + +$(document).ready(function () { + $('#settings_preset_textgenerationwebui').on('change', function() { + const presetName = $(this).val(); + selectPreset(presetName); + }); + for (const i of setting_names) { $(`#${i}_textgenerationwebui`).attr("x-setting-id", i); $(document).on("input", `#${i}_textgenerationwebui`, function () { @@ -80,4 +98,21 @@ $(document).ready(function() { saveSettingsDebounced(); }); } -}) \ No newline at end of file +}) + +function setSettingByName(i, value) { + if (value === null || value === undefined) { + return; + } + + const isCheckbox = $(`#${i}_textgenerationwebui`).attr('type') == 'checkbox'; + if (isCheckbox) { + const val = Boolean(value); + $(`#${i}_textgenerationwebui`).prop('checked', val); + } + else { + const val = parseFloat(value); + $(`#${i}_textgenerationwebui`).val(val); + $(`#${i}_counter_textgenerationwebui`).text(val.toFixed(2)); + } +} diff --git a/server.js b/server.js index 76f508b14..02ddd9a50 100644 --- a/server.js +++ b/server.js @@ -102,6 +102,7 @@ const directories = { novelAI_Settings: 'public/NovelAI Settings', koboldAI_Settings: 'public/KoboldAI Settings', openAI_Settings: 'public/OpenAI Settings', + textGen_Settings: 'public/TextGen Settings', thumbnails: 'thumbnails/', thumbnailsBg: 'thumbnails/bg/', thumbnailsAvatar: 'thumbnails/avatar/', @@ -864,6 +865,8 @@ app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's cod const novelai_setting_names = []; const openai_settings = []; const openai_setting_names = []; + const textgenerationwebui_settings = []; + const textgenerationwebui_setting_names = []; const settings = fs.readFileSync('public/settings.json', 'utf8', (err, data) => { if (err) return response.sendStatus(500); @@ -946,6 +949,30 @@ app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's cod openai_setting_names.push(item.replace(/\.[^/.]+$/, '')); }); + // TextGenerationWebUI + const textGenFiles = fs + .readdirSync(directories.textGen_Settings) + .sort( + (a, b) => + fs.statSync(path.join(directories.textGen_Settings, a)).mtimeMs - + fs.statSync(path.join(directories.textGen_Settings, b)).mtimeMs + ); + + textGenFiles.forEach(item => { + const file = fs.readFileSync( + path.join(directories.textGen_Settings, item), + 'utf8', + (err, data) => { + if (err) return response.sendStatus(500); + + return data; + } + ); + + textgenerationwebui_settings.push(file); + textgenerationwebui_setting_names.push(item.replace(/\.[^/.]+$/, '')); + }); + response.send({ settings, koboldai_settings, @@ -955,6 +982,8 @@ app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's cod novelai_setting_names, openai_settings, openai_setting_names, + textgenerationwebui_settings, + textgenerationwebui_setting_names, enable_extensions: enableExtensions, }); });