From 1f2394cada9f0b450a4333e620068d925968c7c1 Mon Sep 17 00:00:00 2001
From: Cohee <18619528+Cohee1207@users.noreply.github.com>
Date: Wed, 16 Aug 2023 21:43:38 +0300
Subject: [PATCH] Apply preset manager for NovelAI
---
.gitignore | 1 +
public/index.html | 13 ++++++++++---
public/scripts/nai-settings.js | 23 +++++++++++++----------
public/scripts/preset-manager.js | 18 +++++++++++++++++-
4 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/.gitignore b/.gitignore
index f7228af4f..458054342 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ public/css/bg_load.css
public/themes/
public/OpenAI Settings/
public/KoboldAI Settings/
+public/NovelAI Settings/
public/TextGen Settings/
public/scripts/extensions/third-party/
public/stats.json
diff --git a/public/index.html b/public/index.html
index 5c4bfc5d2..233135e62 100644
--- a/public/index.html
+++ b/public/index.html
@@ -160,9 +160,16 @@
?
-
+
diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js
index 47aa56670..c93c6366c 100644
--- a/public/scripts/nai-settings.js
+++ b/public/scripts/nai-settings.js
@@ -2,11 +2,13 @@ import {
getRequestHeaders,
getStoppingStrings,
getTextTokens,
+ max_context,
novelai_setting_names,
- saveSettingsDebounced
+ saveSettingsDebounced,
+ setGenerationParamsFromPreset
} from "../script.js";
import { getCfg } from "./extensions/cfg/util.js";
-import { tokenizers } from "./power-user.js";
+import { MAX_CONTEXT_DEFAULT, tokenizers } from "./power-user.js";
import { getStringHash } from "./utils.js";
export {
@@ -81,16 +83,17 @@ function getNovelTier(tier) {
}
function loadNovelPreset(preset) {
- $("#amount_gen").val(preset.max_length);
- $("#amount_gen_counter").text(`${preset.max_length}`);
- if (((preset.max_context > 2048) && (!$("#max_context_unlocked")[0].checked)) ||
- ((preset.max_context <= 2048) && ($("#max_context_unlocked")[0].checked))) {
- $("#max_context_unlocked").click();
+ if (preset.genamt === undefined) {
+ const needsUnlock = preset.max_context > MAX_CONTEXT_DEFAULT;
+ $("#amount_gen").val(preset.max_length).trigger('input');
+ $('#max_context_unlocked').prop('checked', needsUnlock).trigger('change');
+ $("#max_context").val(preset.max_context).trigger('input');
+ }
+ else {
+ setGenerationParamsFromPreset(preset);
}
- $("#max_context").val(preset.max_context);
- $("#max_context_counter").text(`${preset.max_context}`);
- $("#rep_pen_size_novel").attr('max', preset.max_context);
+ $("#rep_pen_size_novel").attr('max', max_context);
nai_settings.temperature = preset.temperature;
nai_settings.repetition_penalty = preset.repetition_penalty;
nai_settings.repetition_penalty_range = preset.repetition_penalty_range;
diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js
index 0172f98a9..6f0bf5fb8 100644
--- a/public/scripts/preset-manager.js
+++ b/public/scripts/preset-manager.js
@@ -116,6 +116,12 @@ class PresetManager {
Preset name:
Hint: Use a character/group name to bind preset to a specific chat.
`;
const name = await callPopup(popupText, "input");
+
+ if (!name) {
+ console.log('Preset name not provided');
+ return;
+ }
+
await this.savePreset(name);
toastr.success('Preset saved');
}
@@ -214,7 +220,17 @@ class PresetManager {
}
}
- const filteredKeys = ['preset', 'streaming_url', 'stopping_strings', 'use_stop_sequence'];
+ const filteredKeys = [
+ 'preset',
+ 'streaming_url',
+ 'stopping_strings',
+ 'use_stop_sequence',
+ 'preset_settings_novel',
+ 'streaming_novel',
+ 'nai_preamble',
+ 'model_novel',
+ 'preamble',
+ ];
const settings = Object.assign({}, getSettingsByApiId(this.apiId));
for (const key of filteredKeys) {