From b29f63f89ea7a5611c01e7e75c0b3f5c87e52916 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Fri, 27 Oct 2023 03:01:25 +0900 Subject: [PATCH 1/8] fix WI sliders --- public/scripts/world-info.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index fcff2a57c..cb727c9a3 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -135,10 +135,10 @@ function setWorldInfoSettings(settings, data) { world_info = settings.world_info ?? {} - $("#world_info_depth_counter").text(world_info_depth); + $("#world_info_depth_counter").val(world_info_depth); $("#world_info_depth").val(world_info_depth); - $("#world_info_budget_counter").text(world_info_budget); + $("#world_info_budget_counter").val(world_info_budget); $("#world_info_budget").val(world_info_budget); $("#world_info_recursive").prop('checked', world_info_recursive); @@ -150,7 +150,7 @@ function setWorldInfoSettings(settings, data) { $("#world_info_character_strategy").val(world_info_character_strategy); $("#world_info_budget_cap").val(world_info_budget_cap); - $("#world_info_budget_cap_counter").text(world_info_budget_cap); + $("#world_info_budget_cap_counter").val(world_info_budget_cap); world_names = data.world_names?.length ? data.world_names : []; @@ -2043,13 +2043,13 @@ jQuery(() => { $(document).on("input", "#world_info_depth", function () { world_info_depth = Number($(this).val()); - $("#world_info_depth_counter").text($(this).val()); + $("#world_info_depth_counter").val($(this).val()); saveSettings(); }); $(document).on("input", "#world_info_budget", function () { world_info_budget = Number($(this).val()); - $("#world_info_budget_counter").text($(this).val()); + $("#world_info_budget_counter").val($(this).val()); saveSettings(); }); @@ -2080,7 +2080,7 @@ jQuery(() => { $('#world_info_budget_cap').on('input', function () { world_info_budget_cap = Number($(this).val()); - $("#world_info_budget_cap_counter").text(world_info_budget_cap); + $("#world_info_budget_cap_counter").val(world_info_budget_cap); saveSettings(); }); From 24f406917d8f8a2119bf79669a7df05674f08f66 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 26 Oct 2023 21:22:00 +0300 Subject: [PATCH 2/8] Add seed to Kobold APi --- public/index.html | 8 ++++++++ public/scripts/kai-settings.js | 9 +++++++++ public/scripts/preset-manager.js | 1 + server.js | 1 + 4 files changed, 19 insertions(+) diff --git a/public/index.html b/public/index.html index e5f1b3c18..f70458b0d 100644 --- a/public/index.html +++ b/public/index.html @@ -1091,6 +1091,14 @@
+
+
+ Seed +
+ + +
+
Samplers Order diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index 517e32b2f..29d63e729 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -28,6 +28,7 @@ export const kai_settings = { mirostat_eta: 0.1, use_default_badwordsids: false, grammar: "", + seed: -1, }; export const kai_flags = { @@ -136,6 +137,7 @@ export function getKoboldGenerationData(finalPrompt, settings, maxLength, maxCon mirostat_eta: kai_flags.can_use_mirostat ? kai_settings.mirostat_eta : undefined, use_default_badwordsids: kai_flags.can_use_default_badwordsids ? kai_settings.use_default_badwordsids : undefined, grammar: kai_flags.can_use_grammar ? substituteParams(kai_settings.grammar) : undefined, + sampler_seed: kai_settings.seed >= 0 ? kai_settings.seed : undefined, }; return generate_data; } @@ -281,6 +283,13 @@ const sliders = [ format: (val) => val, setValue: (val) => { kai_settings.grammar = val; }, }, + { + name: "seed", + sliderId: "#seed_kobold", + counterId: "#seed_counter_kobold", + format: (val) => val, + setValue: (val) => { kai_settings.seed = Number(val); }, + }, ]; export function setKoboldFlags(version, koboldVersion) { diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index e8a012bab..0d75f40b2 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -262,6 +262,7 @@ class PresetManager { 'model_novel', 'streaming_kobold', "enabled", + 'seed', ]; const settings = Object.assign({}, getSettingsByApiId(this.apiId)); diff --git a/server.js b/server.js index 94dcc9ace..8f6c31f9f 100644 --- a/server.js +++ b/server.js @@ -401,6 +401,7 @@ app.post("/generate", jsonParser, async function (request, response_generate) { mirostat_eta: request.body.mirostat_eta, mirostat_tau: request.body.mirostat_tau, grammar: request.body.grammar, + sampler_seed: request.body.sampler_seed, }; if (!!request.body.stop_sequence) { this_settings['stop_sequence'] = request.body.stop_sequence; From 11cc27d9c92f2e4e251a215d6efc3862d809ab32 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 26 Oct 2023 22:02:56 +0300 Subject: [PATCH 3/8] Increase debounce duration for type-in controls to 2sec --- public/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index edb74c1ce..787d4d9dd 100644 --- a/public/script.js +++ b/public/script.js @@ -8815,7 +8815,7 @@ jQuery(async function () { } restoreCaretPosition($(this).get(0), caretPosition); - }, 500); + }, 2000); }) $(".user_stats_button").on('click', function () { From 167b2d0fe468c8eac04540d04f47d976aad683b9 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 27 Oct 2023 01:03:54 +0300 Subject: [PATCH 4/8] Add exception handling to stats writer --- statsHelpers.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/statsHelpers.js b/statsHelpers.js index ee344d303..c370fa588 100644 --- a/statsHelpers.js +++ b/statsHelpers.js @@ -173,8 +173,12 @@ async function loadStatsFile(chatsPath, charactersPath, recreateStats = false) { async function saveStatsToFile() { if (charStats.timestamp > lastSaveTimestamp) { //console.debug("Saving stats to file..."); - await writeFile(statsFilePath, JSON.stringify(charStats)); - lastSaveTimestamp = Date.now(); + try { + await writeFile(statsFilePath, JSON.stringify(charStats)); + lastSaveTimestamp = Date.now(); + } catch (error) { + console.log("Failed to save stats to file.", error); + } } else { //console.debug('Stats have not changed since last save. Skipping file write.'); } @@ -184,9 +188,9 @@ async function saveStatsToFile() { * Attempts to save charStats to a file and then terminates the process. * If an error occurs during the file write, it logs the error before exiting. */ -async function writeStatsToFileAndExit(charStats) { +async function writeStatsToFileAndExit() { try { - await saveStatsToFile(charStats); + await saveStatsToFile(); } catch (err) { console.error("Failed to write stats to file:", err); } finally { From 410599b287d71f881bf328588621f5f537f005c8 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 27 Oct 2023 02:01:09 +0300 Subject: [PATCH 5/8] Fix unlocked context sliders sanity --- public/scripts/power-user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index ce689e41a..b18168803 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -46,7 +46,7 @@ export { export const MAX_CONTEXT_DEFAULT = 8192; const MAX_CONTEXT_UNLOCKED = 65536; -const unlockedMaxContextStep = 4096 +const unlockedMaxContextStep = 1024 const unlockedMaxContestMin = 8192 const defaultStoryString = "{{#if system}}{{system}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}"; @@ -1087,7 +1087,7 @@ function loadMaxContextUnlocked() { function switchMaxContextSize() { const elements = [$('#max_context'), $('#rep_pen_range'), $('#rep_pen_range_textgenerationwebui')]; const maxValue = power_user.max_context_unlocked ? MAX_CONTEXT_UNLOCKED : MAX_CONTEXT_DEFAULT; - const minValue = power_user.max_context_unlocked ? unlockedMaxContestMin : 0; + const minValue = power_user.max_context_unlocked ? 0 : 0; const steps = power_user.max_context_unlocked ? unlockedMaxContextStep : 256; for (const element of elements) { From 0c36d113bf1abab31efbc0f4989e43dc6bac8670 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:07:56 +0300 Subject: [PATCH 6/8] Add git disclaimer to asset downloader --- public/scripts/extensions.js | 5 +++-- public/scripts/extensions/assets/index.js | 8 ++++++++ public/scripts/extensions/assets/style.css | 8 +++++++- src/extensions.js | 11 +++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js index 0e519c125..810dada5f 100644 --- a/public/scripts/extensions.js +++ b/public/scripts/extensions.js @@ -733,8 +733,9 @@ export async function installExtension(url) { }); if (!request.ok) { - toastr.info(request.statusText, 'Extension installation failed'); - console.error('Extension installation failed', request.status, request.statusText); + const text = await request.text(); + toastr.warning(text || request.statusText, 'Extension installation failed', { timeOut: 5000 }); + console.error('Extension installation failed', request.status, request.statusText, text); return; } diff --git a/public/scripts/extensions/assets/index.js b/public/scripts/extensions/assets/index.js index 78ea75061..fe6cd12ef 100644 --- a/public/scripts/extensions/assets/index.js +++ b/public/scripts/extensions/assets/index.js @@ -55,6 +55,14 @@ function downloadAssetsList(url) { for (const assetType of assetTypes) { let assetTypeMenu = $('
', { id: "assets_audio_ambient_div", class: "assets-list-div" }); assetTypeMenu.append(`

${assetType}

`) + + if (assetType == 'extension') { + assetTypeMenu.append(` +
+ To download extensions from this page, you need to have Git installed. +
`); + } + for (const i in availableAssets[assetType]) { const asset = availableAssets[assetType][i]; const elemId = `assets_install_${assetType}_${i}`; diff --git a/public/scripts/extensions/assets/style.css b/public/scripts/extensions/assets/style.css index 5bd10be56..15c84d723 100644 --- a/public/scripts/extensions/assets/style.css +++ b/public/scripts/extensions/assets/style.css @@ -13,11 +13,17 @@ padding: 5px; } +.assets-list-git { + font-size: calc(var(--mainFontSize) * 0.8); + opacity: 0.8; + margin-bottom: 1em; +} + .assets-list-div h3 { text-transform: capitalize; } -.assets-list-div a { +.assets-list-div i a { color: inherit; } diff --git a/src/extensions.js b/src/extensions.js index 21d2a924a..fec214244 100644 --- a/src/extensions.js +++ b/src/extensions.js @@ -2,6 +2,7 @@ const path = require('path'); const fs = require('fs'); const { default: simpleGit } = require('simple-git'); const sanitize = require('sanitize-filename'); +const commandExistsSync = require('command-exists').sync; const { DIRECTORIES } = require('./constants'); /** @@ -61,12 +62,19 @@ function registerEndpoints(app, jsonParser) { * @returns {void} */ app.post('/api/extensions/install', jsonParser, async (request, response) => { - const git = simpleGit(); + const gitExists = commandExistsSync('git'); + + if (!gitExists) { + return response.status(400).send('Server Error: git is not installed on the system.'); + } + if (!request.body.url) { return response.status(400).send('Bad Request: URL is required in the request body.'); } try { + const git = simpleGit(); + // make sure the third-party directory exists if (!fs.existsSync(path.join(DIRECTORIES.extensions, 'third-party'))) { fs.mkdirSync(path.join(DIRECTORIES.extensions, 'third-party')); @@ -87,7 +95,6 @@ function registerEndpoints(app, jsonParser) { return response.send({ version, author, display_name, extensionPath }); - } catch (error) { console.log('Importing custom content failed', error); return response.status(500).send(`Server Error: ${error.message}`); From 0ad96b6567e42a82eb33fc6f0dff6b0cd534b2ed Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:22:46 +0300 Subject: [PATCH 7/8] Improve context slider sanity --- public/index.html | 5 ++--- public/scripts/power-user.js | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/index.html b/public/index.html index f70458b0d..985dd0451 100644 --- a/public/index.html +++ b/public/index.html @@ -234,11 +234,10 @@
- +
- - +
diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index b18168803..b197d59a0 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -46,8 +46,9 @@ export { export const MAX_CONTEXT_DEFAULT = 8192; const MAX_CONTEXT_UNLOCKED = 65536; -const unlockedMaxContextStep = 1024 -const unlockedMaxContestMin = 8192 +const unlockedMaxContextStep = 256; +const maxContextMin = 512; +const maxContextStep = 64; const defaultStoryString = "{{#if system}}{{system}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}"; const defaultExampleSeparator = '***'; @@ -1087,8 +1088,8 @@ function loadMaxContextUnlocked() { function switchMaxContextSize() { const elements = [$('#max_context'), $('#rep_pen_range'), $('#rep_pen_range_textgenerationwebui')]; const maxValue = power_user.max_context_unlocked ? MAX_CONTEXT_UNLOCKED : MAX_CONTEXT_DEFAULT; - const minValue = power_user.max_context_unlocked ? 0 : 0; - const steps = power_user.max_context_unlocked ? unlockedMaxContextStep : 256; + const minValue = power_user.max_context_unlocked ? maxContextMin : maxContextMin; + const steps = power_user.max_context_unlocked ? unlockedMaxContextStep : maxContextStep; for (const element of elements) { element.attr('max', maxValue); From a2d8a2a447d815f26668b2fdd96f987340e91774 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:23:10 +0300 Subject: [PATCH 8/8] Bump package version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 19eb2d6fa..543111776 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sillytavern", - "version": "1.10.6", + "version": "1.10.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sillytavern", - "version": "1.10.6", + "version": "1.10.7", "hasInstallScript": true, "license": "AGPL-3.0", "dependencies": { diff --git a/package.json b/package.json index 185af0b1d..a55a0f45f 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "type": "git", "url": "https://github.com/SillyTavern/SillyTavern.git" }, - "version": "1.10.6", + "version": "1.10.7", "scripts": { "start": "node server.js", "start-multi": "node server.js --disableCsrf",