From 116f80d95225b95fca8d76f23edc528ffe7d999f Mon Sep 17 00:00:00 2001 From: Cohee1207 <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 12 Aug 2023 18:35:03 +0300 Subject: [PATCH 1/3] #925 Add Mancer name to select --- public/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index cc376206a..cd3c27cb5 100644 --- a/public/index.html +++ b/public/index.html @@ -1498,7 +1498,7 @@ @@ -4078,4 +4078,4 @@ - \ No newline at end of file + From f434a96ad6d6da8ca48b411ba54972d72aae75be Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Sun, 13 Aug 2023 01:47:33 +0900 Subject: [PATCH 2/3] fix double import on char card drop --- public/script.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 64b2dae33..df9f5c2ac 100644 --- a/public/script.js +++ b/public/script.js @@ -8994,7 +8994,9 @@ $(document).ready(function () { $dropzone.removeClass('dragover'); const files = Array.from(event.originalEvent.dataTransfer.files); - await importFromURL(event.originalEvent.dataTransfer.items, files); + if (!files.length) { + await importFromURL(event.originalEvent.dataTransfer.items, files); + } processDroppedFiles(files); }); From dd21091807221f7c947d8fc0f929d96e554a274e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 12 Aug 2023 21:26:51 +0300 Subject: [PATCH 3/3] Selectable NovelAI module --- public/index.html | 15 +++++++++++++ public/scripts/nai-settings.js | 40 +++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index cd3c27cb5..632cac7a8 100644 --- a/public/index.html +++ b/public/index.html @@ -835,6 +835,21 @@
+
+
+ AI Module +
+
+ Change the style of the generated text. Set to Vanilla to use the default style. +
+ +
Preamble diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js index 50e20367f..1a15770fd 100644 --- a/public/scripts/nai-settings.js +++ b/public/scripts/nai-settings.js @@ -26,12 +26,14 @@ const nai_settings = { top_k: 0, top_p: 1, top_a: 1, + top_g: 0, typical_p: 1, min_length: 0, model_novel: "euterpe-v2", preset_settings_novel: "Classic-Euterpe", streaming_novel: false, nai_preamble: default_preamble, + prefix: '', }; const nai_tiers = { @@ -92,6 +94,7 @@ function loadNovelPreset(preset) { nai_settings.top_g = preset.top_g; nai_settings.mirostat_lr = preset.mirostat_lr; nai_settings.mirostat_tau = preset.mirostat_tau; + nai_settings.prefix = preset.prefix; loadNovelSettingsUi(nai_settings); } @@ -121,6 +124,7 @@ function loadNovelSettings(settings) { nai_settings.mirostat_lr = settings.mirostat_lr; nai_settings.mirostat_tau = settings.mirostat_tau; nai_settings.streaming_novel = !!settings.streaming_novel; + nai_settings.prefix = settings.prefix; loadNovelSettingsUi(nai_settings); } @@ -193,6 +197,7 @@ function loadNovelSettingsUi(ui_settings) { $("#min_length_novel").val(ui_settings.min_length); $("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0)); $('#nai_preamble_textarea').val(ui_settings.nai_preamble); + $('#nai_prefix').val(ui_settings.prefix || ""); $("#streaming_novel").prop('checked', ui_settings.streaming_novel); } @@ -302,10 +307,9 @@ const sliders = [ }, ]; -export function getNovelGenerationData(finalPromt, this_settings, this_amount_gen, isImpersonate) { +export function getNovelGenerationData(finalPrompt, this_settings, this_amount_gen, isImpersonate) { const clio = nai_settings.model_novel.includes('clio'); const kayra = nai_settings.model_novel.includes('kayra'); - const isNewModel = clio || kayra; const tokenizerType = kayra ? tokenizers.NERD2 : (clio ? tokenizers.NERD : tokenizers.NONE); const stopSequences = (tokenizerType !== tokenizers.NONE) @@ -313,15 +317,10 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge .map(t => getTextTokens(tokenizerType, t)) : undefined; - let useInstruct = false; - if (isNewModel) { - // NovelAI claims they scan backwards 1000 characters (not tokens!) to look for instruct brackets. That's really short. - const tail = finalPromt.slice(-1500); - useInstruct = tail.includes("}"); - } + const prefix = nai_settings.prefix || autoSelectPrefix(finalPrompt); return { - "input": finalPromt, + "input": finalPrompt, "model": nai_settings.model_novel, "use_string": true, "temperature": parseFloat(nai_settings.temperature), @@ -350,12 +349,28 @@ export function getNovelGenerationData(finalPromt, this_settings, this_amount_ge "use_cache": false, "use_string": true, "return_full_text": false, - "prefix": useInstruct ? "special_instruct" : (isNewModel ? "special_proseaugmenter" : "vanilla"), + "prefix": prefix, "order": this_settings.order, "streaming": nai_settings.streaming_novel, }; } +function autoSelectPrefix(finalPromt) { + let useInstruct = false; + const clio = nai_settings.model_novel.includes('clio'); + const kayra = nai_settings.model_novel.includes('kayra'); + const isNewModel = clio || kayra; + + if (isNewModel) { + // NovelAI claims they scan backwards 1000 characters (not tokens!) to look for instruct brackets. That's really short. + const tail = finalPromt.slice(-1500); + useInstruct = tail.includes("}"); + } + + const prefix = useInstruct ? "special_instruct" : (isNewModel ? "special_proseaugmenter" : "vanilla"); + return prefix; +} + export async function generateNovelWithStreaming(generate_data, signal) { const response = await fetch('/generate_novelai', { headers: getRequestHeaders(), @@ -431,4 +446,9 @@ $(document).ready(function () { nai_settings.model_novel = $("#model_novel_select").find(":selected").val(); saveSettingsDebounced(); }); + + $("#nai_prefix").on('change', function () { + nai_settings.prefix = $("#nai_prefix").find(":selected").val(); + saveSettingsDebounced(); + }); });