Merge pull request #1292 from SillyTavern/staging

Staging
This commit is contained in:
Cohee 2023-10-27 13:26:43 +03:00 committed by GitHub
commit 9be3645152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 65 additions and 20 deletions

4
package-lock.json generated
View File

@ -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": {

View File

@ -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",

View File

@ -234,11 +234,10 @@
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range">
<input type="range" id="max_context" name="volume" min="512" max="4096" step="512">
<input type="range" id="max_context" name="volume" min="512" max="8192" step="64">
</div>
<div class="range-block-counter" data-randomization-disabled="true">
<input type="number" min="512" max="4096" step="512" data-for="max_context" id="max_context_counter">
<input type="number" min="512" max="8192" step="64" data-for="max_context" id="max_context_counter">
</div>
</div>
</div>
@ -1091,6 +1090,14 @@
</div>
</div>
<hr>
<div class="range-block">
<div class="range-block-title" data-i18n="Seed">
Seed
</div>
<!-- Max value is 2**64 - 1 -->
<input type="number" id="seed_kobold" class="text_pole wide100p" min="-1" value="-1" max="18446744073709551615" />
</div>
<hr>
<div class="range-block flexFlowColumn">
<div class="range-block-title">
<span data-i18n="Samplers Order">Samplers Order</span>

View File

@ -8815,7 +8815,7 @@ jQuery(async function () {
}
restoreCaretPosition($(this).get(0), caretPosition);
}, 500);
}, 2000);
})
$(".user_stats_button").on('click', function () {

View File

@ -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;
}

View File

@ -55,6 +55,14 @@ function downloadAssetsList(url) {
for (const assetType of assetTypes) {
let assetTypeMenu = $('<div />', { id: "assets_audio_ambient_div", class: "assets-list-div" });
assetTypeMenu.append(`<h3>${assetType}</h3>`)
if (assetType == 'extension') {
assetTypeMenu.append(`
<div class="assets-list-git">
To download extensions from this page, you need to have <a href="https://git-scm.com/downloads" target="_blank">Git</a> installed.
</div>`);
}
for (const i in availableAssets[assetType]) {
const asset = availableAssets[assetType][i];
const elemId = `assets_install_${assetType}_${i}`;

View File

@ -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;
}

View File

@ -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) {

View File

@ -46,8 +46,9 @@ export {
export const MAX_CONTEXT_DEFAULT = 8192;
const MAX_CONTEXT_UNLOCKED = 65536;
const unlockedMaxContextStep = 4096
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 ? unlockedMaxContestMin : 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);

View File

@ -262,6 +262,7 @@ class PresetManager {
'model_novel',
'streaming_kobold',
"enabled",
'seed',
];
const settings = Object.assign({}, getSettingsByApiId(this.apiId));

View File

@ -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;

View File

@ -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}`);

View File

@ -173,8 +173,12 @@ async function loadStatsFile(chatsPath, charactersPath, recreateStats = false) {
async function saveStatsToFile() {
if (charStats.timestamp > lastSaveTimestamp) {
//console.debug("Saving stats to file...");
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 {