Merge branch 'SillyTavern:staging' into staging

This commit is contained in:
Tony Ribeiro
2023-08-18 17:43:18 +02:00
committed by GitHub
14 changed files with 105 additions and 83 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "Default", "name": "Default",
"story_string": "{{#if description}}{{{description}}}{{/if}}\n{{#if personality}}{{{personality}}}{{/if}}\n{{#if scenario}}Scenario: {{{scenario}}}{{/if}}", "story_string": "{{#if description}}{{description}}{{/if}}\n{{#if personality}}{{personality}}{{/if}}\n{{#if scenario}}Scenario: {{scenario}}{{/if}}",
"chat_start": "***", "chat_start": "***",
"example_separator": "***" "example_separator": "***"
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "Pygmalion", "name": "Pygmalion",
"story_string": "{{#if description}}{{{char}}}'s Persona: {{{description}}}{{/if}}\n{{#if personality}}Personality: {{{personality}}}{{/if}}\n{{#if scenario}}Scenario: {{{scenario}}}{{/if}}", "story_string": "{{#if description}}{{{char}}}'s Persona: {{description}}{{/if}}\n{{#if personality}}Personality: {{personality}}{{/if}}\n{{#if scenario}}Scenario: {{scenario}}{{/if}}",
"chat_start": "<START>", "chat_start": "<START>",
"example_separator": "<START>" "example_separator": "<START>"
} }

View File

@@ -208,8 +208,7 @@
<div class="range-block-title justifyLeft"> <div class="range-block-title justifyLeft">
AI Module AI Module
</div> </div>
<div class="toggle-description justifyLeft" <div class="toggle-description justifyLeft" data-i18n="Changes the style of the generated text.">
data-i18n="Changes the style of the generated text.">
Changes the style of the generated text. Changes the style of the generated text.
</div> </div>
<select id="nai_prefix"> <select id="nai_prefix">
@@ -937,7 +936,7 @@
<span data-i18n="Negative Prompt">Negative Prompt</span> <span data-i18n="Negative Prompt">Negative Prompt</span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="nai_cfg_uc" class="text_pole textarea_compact" name="cfg_uc" rows="2" data-i18n="[placeholder]Add text here that would make the AI generate things you don't want in your outputs." placeholder="Add text here that would make the AI generate things you don't want in your outputs."></textarea> <textarea id="nai_cfg_uc" class="text_pole textarea_compact" name="cfg_uc" rows="2" data-i18n="[placeholder]Add text here that would make the AI generate things you don't want in your outputs." placeholder="Add text here that would make the AI generate things you don't want in your outputs."></textarea>
</div> </div>
</div> </div>
<small class="margin-bot-10px" data-i18n="Used if CFG Scale is unset globally, per chat or character"> <small class="margin-bot-10px" data-i18n="Used if CFG Scale is unset globally, per chat or character">
@@ -1266,7 +1265,7 @@
<span data-i18n="Negative Prompt">Negative Prompt</span> <span data-i18n="Negative Prompt">Negative Prompt</span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="negative_prompt_textgenerationwebui" class="text_pole textarea_compact" name="negative_prompt" rows="2" data-i18n="[placeholder]Add text here that would make the AI generate things you don't want in your outputs." placeholder="Add text here that would make the AI generate things you don't want in your outputs."></textarea> <textarea id="negative_prompt_textgenerationwebui" class="text_pole textarea_compact" name="negative_prompt" rows="2" data-i18n="[placeholder]Add text here that would make the AI generate things you don't want in your outputs." placeholder="Add text here that would make the AI generate things you don't want in your outputs."></textarea>
</div> </div>
</div> </div>
<small class="margin-bot-10px" data-i18n="Used if CFG Scale is unset globally, per chat or character"> <small class="margin-bot-10px" data-i18n="Used if CFG Scale is unset globally, per chat or character">
@@ -1477,8 +1476,7 @@
<div class="fa-solid fa-clock-rotate-left"></div> <div class="fa-solid fa-clock-rotate-left"></div>
</div> </div>
</div> </div>
<div class="toggle-description justifyLeft" <div class="toggle-description justifyLeft" data-i18n="Prompt that is used when the NSFW toggle is O">
data-i18n="Prompt that is used when the NSFW toggle is O">
Prompt that is used when the NSFW toggle is OFF Prompt that is used when the NSFW toggle is OFF
</div> </div>
<div class="wide100p"> <div class="wide100p">
@@ -1494,9 +1492,9 @@
</div> </div>
</div> </div>
<div class="toggle-description justifyLeft"> <div class="toggle-description justifyLeft">
<span data-i18n="Set at the beginning of the chat history to indicate that a new chat is about to start."> <span data-i18n="Set at the beginning of the chat history to indicate that a new chat is about to start.">
Set at the beginning of the chat history to indicate that a new chat is about to start. Set at the beginning of the chat history to indicate that a new chat is about to start.
</span> </span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="newchat_prompt_textarea" class="text_pole textarea_compact" name="new_chat" rows="3" placeholder=""></textarea> <textarea id="newchat_prompt_textarea" class="text_pole textarea_compact" name="new_chat" rows="3" placeholder=""></textarea>
@@ -1510,9 +1508,9 @@
</div> </div>
</div> </div>
<div class="toggle-description justifyLeft"> <div class="toggle-description justifyLeft">
<span data-i18n="Set at the beginning of the chat history to indicate that a new group chat is about to start."> <span data-i18n="Set at the beginning of the chat history to indicate that a new group chat is about to start.">
Set at the beginning of the chat history to indicate that a new group chat is about to start. Set at the beginning of the chat history to indicate that a new group chat is about to start.
</span> </span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="newgroupchat_prompt_textarea" class="text_pole textarea_compact" name="new_group_chat" rows="3" placeholder=""></textarea> <textarea id="newgroupchat_prompt_textarea" class="text_pole textarea_compact" name="new_group_chat" rows="3" placeholder=""></textarea>
@@ -1526,9 +1524,9 @@
</div> </div>
</div> </div>
<div class="toggle-description justifyLeft"> <div class="toggle-description justifyLeft">
<span data-i18n="Set at the beginning of Dialogue examples to indicate that a new example chat is about to start."> <span data-i18n="Set at the beginning of Dialogue examples to indicate that a new example chat is about to start.">
Set at the beginning of Dialogue examples to indicate that a new example chat is about to start. Set at the beginning of Dialogue examples to indicate that a new example chat is about to start.
</span> </span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="newexamplechat_prompt_textarea" class="text_pole textarea_compact" name="new_example_chat" rows="3" placeholder=""></textarea> <textarea id="newexamplechat_prompt_textarea" class="text_pole textarea_compact" name="new_example_chat" rows="3" placeholder=""></textarea>
@@ -1542,9 +1540,9 @@
</div> </div>
</div> </div>
<div class="toggle-description justifyLeft"> <div class="toggle-description justifyLeft">
<span data-i18n="Set at the beginning of the chat history to indicate that a new chat is about to start."> <span data-i18n="Set at the beginning of the chat history to indicate that a new chat is about to start.">
Set at the end of the chat history when the continue button is pressed. Set at the end of the chat history when the continue button is pressed.
</span> </span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="continue_nudge_prompt_textarea" class="text_pole textarea_compact" name="continue_nudge" rows="3" placeholder=""></textarea> <textarea id="continue_nudge_prompt_textarea" class="text_pole textarea_compact" name="continue_nudge" rows="3" placeholder=""></textarea>
@@ -1555,9 +1553,9 @@
Replace empty message Replace empty message
</div> </div>
<div class="toggle-description justifyLeft"> <div class="toggle-description justifyLeft">
<span data-i18n="Send this text instead of nothing when the text box is empty."> <span data-i18n="Send this text instead of nothing when the text box is empty.">
Send this text instead of nothing when the text box is empty. Send this text instead of nothing when the text box is empty.
</span> </span>
</div> </div>
<div class="wide100p"> <div class="wide100p">
<textarea id="send_if_empty_textarea" class="text_pole textarea_compact" name="send_if_empty" rows="3" placeholder=""></textarea> <textarea id="send_if_empty_textarea" class="text_pole textarea_compact" name="send_if_empty" rows="3" placeholder=""></textarea>
@@ -2990,6 +2988,7 @@
<div id="rm_button_selected_ch"> <div id="rm_button_selected_ch">
<h2></h2> <h2></h2>
</div> </div>
<i id="hideCharPanelAvatarButton" class="fa-solid fa-eye menu_button"></i>
</div> </div>
</div> </div>
<!-- end group peeking cope structure--> <!-- end group peeking cope structure-->
@@ -3004,7 +3003,7 @@
<input id="character_name_pole" name="ch_name" class="text_pole" data-i18n="[placeholder]Name this character" placeholder="Name this character" maxlength="50" value="" autocomplete="off"> <input id="character_name_pole" name="ch_name" class="text_pole" data-i18n="[placeholder]Name this character" placeholder="Name this character" maxlength="50" value="" autocomplete="off">
</div> </div>
<div id="result_info" class="flex-container" title="Token counts may be inaccurate and provided just for reference." data-i18n="[title]Token counts may be inaccurate and provided just for reference.">&nbsp;</div>
<div id="avatar_div" class="avatar_div alignitemsflexstart justifySpaceBetween flexnowrap flexGap5"> <div id="avatar_div" class="avatar_div alignitemsflexstart justifySpaceBetween flexnowrap flexGap5">
<label id="avatar_div_div" class="add_avatar avatar" for="add_avatar_button" title="Click to select a new avatar for this character" data-i18n="[title]Click to select a new avatar for this character"> <label id="avatar_div_div" class="add_avatar avatar" for="add_avatar_button" title="Click to select a new avatar for this character" data-i18n="[title]Click to select a new avatar for this character">
@@ -3077,6 +3076,7 @@
<div id="description_div" class="marginBot5"> <div id="description_div" class="marginBot5">
<span data-i18n="Character Description">Description</span> <span data-i18n="Character Description">Description</span>
<div id="result_info" class="flex-container" title="Token counts may be inaccurate and provided just for reference." data-i18n="[title]Token counts may be inaccurate and provided just for reference.">&nbsp;</div>
<a href="https://docs.sillytavern.app/usage/core-concepts/characterdesign/#character-description" class="notes-link" target="_blank"> <a href="https://docs.sillytavern.app/usage/core-concepts/characterdesign/#character-description" class="notes-link" target="_blank">
<span class="note-link-span">?</span> <span class="note-link-span">?</span>
</a> </a>
@@ -3792,10 +3792,10 @@
<input class="openai_logit_bias_text text_pole" data-i18n="[placeholder]Type here..." placeholder="type here..." /> <input class="openai_logit_bias_text text_pole" data-i18n="[placeholder]Type here..." placeholder="type here..." />
<input class="openai_logit_bias_value text_pole" type="number" min="-100" value="0" max="100" /> <input class="openai_logit_bias_value text_pole" type="number" min="-100" value="0" max="100" />
<i class="menu_button fa-solid fa-xmark openai_logit_bias_remove"></i> <i class="menu_button fa-solid fa-xmark openai_logit_bias_remove"></i>
</form> </form>
</div>
</div> </div>
</div> </div>
</div>
<div id="novelai_logit_bias_template" class="template_element"> <div id="novelai_logit_bias_template" class="template_element">
<div class="novelai_logit_bias_form"> <div class="novelai_logit_bias_form">
@@ -3853,7 +3853,7 @@
<textarea id="completion_prompt_manager_popup_entry_form_prompt" class="text_pole" name="prompt"> <textarea id="completion_prompt_manager_popup_entry_form_prompt" class="text_pole" name="prompt">
</textarea> </textarea>
</div> </div>
<div class="completion_prompt_manager_popup_entry_form_footer" > <div class="completion_prompt_manager_popup_entry_form_footer">
<a id="completion_prompt_manager_popup_entry_form_close" title="close" class="fa-solid fa-close menu_button"></a> <a id="completion_prompt_manager_popup_entry_form_close" title="close" class="fa-solid fa-close menu_button"></a>
<a id="completion_prompt_manager_popup_entry_form_reset" title="reset" class="fa-solid fa-undo menu_button"></a> <a id="completion_prompt_manager_popup_entry_form_reset" title="reset" class="fa-solid fa-undo menu_button"></a>
<a id="completion_prompt_manager_popup_entry_form_save" title="save" class="fa-solid fa-save menu_button" data-pm-prompt=""></a> <a id="completion_prompt_manager_popup_entry_form_save" title="save" class="fa-solid fa-save menu_button" data-pm-prompt=""></a>
@@ -4286,4 +4286,4 @@
</script> </script>
</body> </body>
</html> </html>

View File

@@ -2442,9 +2442,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
mesExamples = ''; mesExamples = '';
} }
// OpenAI handler always expects it const exampleSeparator = power_user.context.example_separator ? `${power_user.context.example_separator}\n` : '';
const blockHeading = main_api === 'openai' ? '<START>' : (power_user.context.example_separator || ''); const blockHeading = main_api === 'openai' ? '<START>\n' : exampleSeparator;
let mesExamplesArray = mesExamples.split(/<START>/gi).slice(1).map(block => `${blockHeading}\n${block.trim()}\n`); let mesExamplesArray = mesExamples.split(/<START>/gi).slice(1).map(block => `${blockHeading}${block.trim()}\n`);
// First message in fresh 1-on-1 chat reacts to user/character settings changes // First message in fresh 1-on-1 chat reacts to user/character settings changes
if (chat.length) { if (chat.length) {
@@ -2900,7 +2900,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
} }
} }
if (true === dryRun) return onSuccess({error: 'dryRun'}); if (true === dryRun) return onSuccess({ error: 'dryRun' });
if (power_user.console_log_prompts) { if (power_user.console_log_prompts) {
@@ -4452,7 +4452,7 @@ async function getChat() {
} }
await getChatResult(); await getChatResult();
await saveChat(); await saveChat();
eventSource.emit('chatLoaded', {detail: {id: this_chid, character: characters[this_chid]}}); eventSource.emit('chatLoaded', { detail: { id: this_chid, character: characters[this_chid] } });
setTimeout(function () { setTimeout(function () {
@@ -6591,7 +6591,7 @@ async function createOrEditCharacter(e) {
); );
$("#create_button").attr("value", "Save"); $("#create_button").attr("value", "Save");
crop_data = undefined; crop_data = undefined;
eventSource.emit(event_types.CHARACTER_EDITED, {detail: {id: this_chid, character: characters[this_chid]}}); eventSource.emit(event_types.CHARACTER_EDITED, { detail: { id: this_chid, character: characters[this_chid] } });
}, },
error: function (jqXHR, exception) { error: function (jqXHR, exception) {
$("#create_button").removeAttr("disabled"); $("#create_button").removeAttr("disabled");
@@ -7643,7 +7643,7 @@ $(document).ready(function () {
if (popup_type == "del_ch") { if (popup_type == "del_ch") {
const deleteChats = !!$("#del_char_checkbox").prop("checked"); const deleteChats = !!$("#del_char_checkbox").prop("checked");
await handleDeleteCharacter(popup_type, this_chid, deleteChats); await handleDeleteCharacter(popup_type, this_chid, deleteChats);
eventSource.emit('characterDeleted', {id: this_chid, character: characters[this_chid]}); eventSource.emit('characterDeleted', { id: this_chid, character: characters[this_chid] });
} }
if (popup_type == "alternate_greeting" && menu_type !== "create") { if (popup_type == "alternate_greeting" && menu_type !== "create") {
createOrEditCharacter(); createOrEditCharacter();
@@ -9144,4 +9144,9 @@ $(document).ready(function () {
$("#charListGridToggle").on('click', async () => { $("#charListGridToggle").on('click', async () => {
doCharListDisplaySwitch(); doCharListDisplaySwitch();
}); });
$("#hideCharPanelAvatarButton").on('click', () => {
$('#avatar-and-name-block').slideToggle()
})
}); });

View File

@@ -2,7 +2,7 @@ import {callPopup, event_types, eventSource, is_send_press, main_api, substitute
import { is_group_generating } from "./group-chats.js"; import { is_group_generating } from "./group-chats.js";
import {TokenHandler} from "./openai.js"; import {TokenHandler} from "./openai.js";
import {power_user} from "./power-user.js"; import {power_user} from "./power-user.js";
import { debounce, waitUntilCondition } from "./utils.js"; import { debounce, getSortableDelay, waitUntilCondition } from "./utils.js";
function debouncePromise(func, delay) { function debouncePromise(func, delay) {
let timeoutId; let timeoutId;
@@ -1511,6 +1511,7 @@ PromptManagerModule.prototype.getFormattedDate = function() {
*/ */
PromptManagerModule.prototype.makeDraggable = function () { PromptManagerModule.prototype.makeDraggable = function () {
$(`#${this.configuration.prefix}prompt_manager_list`).sortable({ $(`#${this.configuration.prefix}prompt_manager_list`).sortable({
delay: getSortableDelay(),
items: `.${this.configuration.prefix}prompt_manager_prompt_draggable`, items: `.${this.configuration.prefix}prompt_manager_prompt_draggable`,
update: ( event, ui ) => { update: ( event, ui ) => {
const promptOrder = this.getPromptOrderForCharacter(this.activeCharacter); const promptOrder = this.getPromptOrderForCharacter(this.activeCharacter);

View File

@@ -48,7 +48,7 @@
z-index: 2; z-index: 2;
overflow: hidden; overflow: hidden;
resize: both; resize: both;
display: flex;
} }
img.expression { img.expression {
@@ -56,7 +56,6 @@ img.expression {
min-height: 100px; min-height: 100px;
max-height: 90vh; max-height: 90vh;
max-width: 90vh; max-width: 90vh;
width: 100%;
top: 0; top: 0;
bottom: 0; bottom: 0;
padding: 0; padding: 0;
@@ -181,4 +180,4 @@ img.expression.default {
div.expression { div.expression {
display: none; display: none;
} }
} }

View File

@@ -1,6 +1,6 @@
import { callPopup, eventSource, event_types, getCurrentChatId, reloadCurrentChat, saveSettingsDebounced } from "../../../script.js"; import { callPopup, getCurrentChatId, reloadCurrentChat, saveSettingsDebounced } from "../../../script.js";
import { extension_settings } from "../../extensions.js"; import { extension_settings } from "../../extensions.js";
import { uuidv4, waitUntilCondition } from "../../utils.js"; import { getSortableDelay, uuidv4 } from "../../utils.js";
import { regex_placement } from "./engine.js"; import { regex_placement } from "./engine.js";
async function saveRegexScript(regexScript, existingScriptIndex) { async function saveRegexScript(regexScript, existingScriptIndex) {
@@ -236,6 +236,7 @@ jQuery(async () => {
}); });
$('#saved_regex_scripts').sortable({ $('#saved_regex_scripts').sortable({
delay: getSortableDelay(),
stop: function () { stop: function () {
let newScripts = []; let newScripts = [];
$('#saved_regex_scripts').children().each(function () { $('#saved_regex_scripts').children().each(function () {

View File

@@ -7,6 +7,7 @@ import {
import { import {
power_user, power_user,
} from "./power-user.js"; } from "./power-user.js";
import { getSortableDelay } from "./utils.js";
export { export {
kai_settings, kai_settings,
@@ -243,7 +244,7 @@ function sortItemsByOrder(orderArray) {
} }
} }
$(document).ready(function () { jQuery(function () {
sliders.forEach(slider => { sliders.forEach(slider => {
$(document).on("input", slider.sliderId, function () { $(document).on("input", slider.sliderId, function () {
const value = $(this).val(); const value = $(this).val();
@@ -267,6 +268,7 @@ $(document).ready(function () {
}); });
$('#kobold_order').sortable({ $('#kobold_order').sortable({
delay: getSortableDelay(),
stop: function () { stop: function () {
const order = []; const order = [];
$('#kobold_order').children().each(function () { $('#kobold_order').children().each(function () {

View File

@@ -10,8 +10,9 @@ import {
import { getCfg } from "./extensions/cfg/util.js"; import { getCfg } from "./extensions/cfg/util.js";
import { MAX_CONTEXT_DEFAULT, tokenizers } from "./power-user.js"; import { MAX_CONTEXT_DEFAULT, tokenizers } from "./power-user.js";
import { import {
getSortableDelay,
getStringHash, getStringHash,
uuidv4 uuidv4,
} from "./utils.js"; } from "./utils.js";
export { export {
@@ -47,7 +48,7 @@ const nai_settings = {
model_novel: "clio-v1", model_novel: "clio-v1",
preset_settings_novel: "Talker-Chat-Clio", preset_settings_novel: "Talker-Chat-Clio",
streaming_novel: false, streaming_novel: false,
nai_preamble: default_preamble, preamble: default_preamble,
prefix: '', prefix: '',
cfg_uc: '', cfg_uc: '',
banned_tokens: '', banned_tokens: '',
@@ -120,6 +121,7 @@ function loadNovelPreset(preset) {
nai_settings.banned_tokens = preset.banned_tokens || ''; nai_settings.banned_tokens = preset.banned_tokens || '';
nai_settings.order = preset.order || default_order; nai_settings.order = preset.order || default_order;
nai_settings.logit_bias = preset.logit_bias || []; nai_settings.logit_bias = preset.logit_bias || [];
nai_settings.preamble = preset.preamble || default_preamble;
loadNovelSettingsUi(nai_settings); loadNovelSettingsUi(nai_settings);
} }
@@ -129,7 +131,10 @@ function loadNovelSettings(settings) {
$(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true); $(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true);
$('#model_novel_select').val(nai_settings.model_novel); $('#model_novel_select').val(nai_settings.model_novel);
if (settings.nai_preamble !== undefined) nai_settings.preamble = settings.nai_preamble; if (settings.nai_preamble !== undefined) {
nai_settings.preamble = settings.nai_preamble;
delete settings.nai_preamble;
}
nai_settings.preset_settings_novel = settings.preset_settings_novel; nai_settings.preset_settings_novel = settings.preset_settings_novel;
nai_settings.temperature = settings.temperature; nai_settings.temperature = settings.temperature;
nai_settings.repetition_penalty = settings.repetition_penalty; nai_settings.repetition_penalty = settings.repetition_penalty;
@@ -163,6 +168,7 @@ function loadNovelSettingsUi(ui_settings) {
$("#rep_pen_novel").val(ui_settings.repetition_penalty); $("#rep_pen_novel").val(ui_settings.repetition_penalty);
$("#rep_pen_counter_novel").text(Number(ui_settings.repetition_penalty).toFixed(2)); $("#rep_pen_counter_novel").text(Number(ui_settings.repetition_penalty).toFixed(2));
$("#rep_pen_size_novel").val(ui_settings.repetition_penalty_range); $("#rep_pen_size_novel").val(ui_settings.repetition_penalty_range);
$("#rep_pen_size_novel").attr('max', max_context);
$("#rep_pen_size_counter_novel").text(Number(ui_settings.repetition_penalty_range).toFixed(0)); $("#rep_pen_size_counter_novel").text(Number(ui_settings.repetition_penalty_range).toFixed(0));
$("#rep_pen_slope_novel").val(ui_settings.repetition_penalty_slope); $("#rep_pen_slope_novel").val(ui_settings.repetition_penalty_slope);
$("#rep_pen_slope_counter_novel").text(Number(`${ui_settings.repetition_penalty_slope}`).toFixed(2)); $("#rep_pen_slope_counter_novel").text(Number(`${ui_settings.repetition_penalty_slope}`).toFixed(2));
@@ -189,7 +195,7 @@ function loadNovelSettingsUi(ui_settings) {
$("#mirostat_tau_counter_novel").text(Number(ui_settings.mirostat_tau).toFixed(2)); $("#mirostat_tau_counter_novel").text(Number(ui_settings.mirostat_tau).toFixed(2));
$("#min_length_novel").val(ui_settings.min_length); $("#min_length_novel").val(ui_settings.min_length);
$("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0)); $("#min_length_counter_novel").text(Number(ui_settings.min_length).toFixed(0));
$('#nai_preamble_textarea').val(ui_settings.nai_preamble); $('#nai_preamble_textarea').val(ui_settings.preamble);
$('#nai_prefix').val(ui_settings.prefix || "vanilla"); $('#nai_prefix').val(ui_settings.prefix || "vanilla");
$('#nai_cfg_uc').val(ui_settings.cfg_uc || ""); $('#nai_cfg_uc').val(ui_settings.cfg_uc || "");
$('#nai_banned_tokens').val(ui_settings.banned_tokens || ""); $('#nai_banned_tokens').val(ui_settings.banned_tokens || "");
@@ -443,7 +449,6 @@ export function getNovelGenerationData(finalPrompt, this_settings, this_amount_g
"return_full_text": false, "return_full_text": false,
"prefix": prefix, "prefix": prefix,
"order": nai_settings.order || this_settings.order || default_order, "order": nai_settings.order || this_settings.order || default_order,
"streaming": nai_settings.streaming_novel,
}; };
} }
@@ -585,6 +590,8 @@ export function adjustNovelInstructionPrompt(prompt) {
} }
export async function generateNovelWithStreaming(generate_data, signal) { export async function generateNovelWithStreaming(generate_data, signal) {
generate_data.streaming = nai_settings.streaming_novel;
const response = await fetch('/generate_novelai', { const response = await fetch('/generate_novelai', {
headers: getRequestHeaders(), headers: getRequestHeaders(),
body: JSON.stringify(generate_data), body: JSON.stringify(generate_data),
@@ -637,7 +644,7 @@ $("#nai_preamble_restore").on('click', function () {
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$(document).ready(function () { jQuery(function () {
sliders.forEach(slider => { sliders.forEach(slider => {
$(document).on("input", slider.sliderId, function () { $(document).on("input", slider.sliderId, function () {
const value = $(this).val(); const value = $(this).val();
@@ -676,6 +683,7 @@ $(document).ready(function () {
}); });
$('#novel_order').sortable({ $('#novel_order').sortable({
delay: getSortableDelay(),
stop: saveSamplingOrder, stop: saveSamplingOrder,
}); });

View File

@@ -46,9 +46,9 @@ export {
export const MAX_CONTEXT_DEFAULT = 4096; export const MAX_CONTEXT_DEFAULT = 4096;
const MAX_CONTEXT_UNLOCKED = 65536; const MAX_CONTEXT_UNLOCKED = 65536;
const defaultStoryString = `{{#if description}}{{{description}}}{{/if}} const defaultStoryString = `{{#if description}}{{description}}{{/if}}
{{#if personality}}{{{personality}}}{{/if}} {{#if personality}}{{personality}}{{/if}}
{{#if scenario}}Scenario: {{{scenario}}}{{/if}}`; {{#if scenario}}Scenario: {{scenario}}{{/if}}`;
const defaultExampleSeparator = '***'; const defaultExampleSeparator = '***';
const defaultChatStart = '***'; const defaultChatStart = '***';
@@ -1042,7 +1042,7 @@ export function fuzzySearchGroups(searchValue) {
export function renderStoryString(params) { export function renderStoryString(params) {
try { try {
const compiledTemplate = Handlebars.compile(power_user.context.story_string); const compiledTemplate = Handlebars.compile(power_user.context.story_string, { noEscape: true });
let output = compiledTemplate(params); let output = compiledTemplate(params);
output = substituteParams(output, params.user, params.char); output = substituteParams(output, params.user, params.char);
output = `${output.trim()}\n`; // add a newline to the end output = `${output.trim()}\n`; // add a newline to the end

View File

@@ -229,7 +229,6 @@ class PresetManager {
'streaming_novel', 'streaming_novel',
'nai_preamble', 'nai_preamble',
'model_novel', 'model_novel',
'preamble',
]; ];
const settings = Object.assign({}, getSettingsByApiId(this.apiId)); const settings = Object.assign({}, getSettingsByApiId(this.apiId));

View File

@@ -8,6 +8,11 @@ export function isDigitsOnly(str) {
return /^\d+$/.test(str); return /^\d+$/.test(str);
} }
// Increase delay on touch screens
export function getSortableDelay() {
return navigator.maxTouchPoints > 0 ? 750 : 100;
}
export function shuffle(array) { export function shuffle(array) {
let currentIndex = array.length, let currentIndex = array.length,
randomIndex; randomIndex;

View File

@@ -1,5 +1,5 @@
import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types } from "../script.js"; import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types } from "../script.js";
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, delay, getCharaFilename, deepClone } from "./utils.js"; import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, deepClone, getSortableDelay, escapeRegex } from "./utils.js";
import { getContext } from "./extensions.js"; import { getContext } from "./extensions.js";
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js"; import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js";
import { registerSlashCommand } from "./slash-commands.js"; import { registerSlashCommand } from "./slash-commands.js";
@@ -302,6 +302,7 @@ function displayWorldEntries(name, data) {
} }
$("#world_popup_entries_list").sortable({ $("#world_popup_entries_list").sortable({
delay: getSortableDelay(),
handle: ".drag-handle", handle: ".drag-handle",
stop: async function (event, ui) { stop: async function (event, ui) {
$('#world_popup_entries_list .world_entry').each(function (index) { $('#world_popup_entries_list .world_entry').each(function (index) {
@@ -1129,7 +1130,7 @@ function matchKeys(haystack, needle) {
return haystack.includes(transformedString); return haystack.includes(transformedString);
} }
else { else {
const regex = new RegExp(`\\b${transformedString}\\b`); const regex = new RegExp(`\\b${escapeRegex(transformedString)}\\b`);
if (regex.test(haystack)) { if (regex.test(haystack)) {
return true; return true;
} }

View File

@@ -69,7 +69,6 @@ app.use(responseTime());
const fs = require('fs'); const fs = require('fs');
const writeFileAtomicSync = require('write-file-atomic').sync; const writeFileAtomicSync = require('write-file-atomic').sync;
const writeFileAtomic = require('write-file-atomic');
const readline = require('readline'); const readline = require('readline');
const open = require('open'); const open = require('open');
@@ -1446,18 +1445,16 @@ app.post('/deleteuseravatar', jsonParser, function (request, response) {
}); });
app.post("/setbackground", jsonParser, function (request, response) { app.post("/setbackground", jsonParser, function (request, response) {
var bg = "#bg1 {background-image: url('../backgrounds/" + request.body.bg + "');}"; try {
writeFileAtomic('public/css/bg_load.css', bg, 'utf8', function (err) { const bg = `#bg1 {background-image: url('../backgrounds/${request.body.bg}');}`;
if (err) { writeFileAtomicSync('public/css/bg_load.css', bg, 'utf8');
response.send(err); response.send({ result: 'ok' });
return console.log(err); } catch (err) {
} else { console.log(err);
//response.redirect("/"); response.send(err);
response.send({ result: 'ok' }); }
}
});
}); });
app.post("/delbackground", jsonParser, function (request, response) { app.post("/delbackground", jsonParser, function (request, response) {
if (!request.body) return response.sendStatus(400); if (!request.body) return response.sendStatus(400);
@@ -1548,14 +1545,13 @@ app.post("/downloadbackground", urlencodedParser, function (request, response) {
}); });
app.post("/savesettings", jsonParser, function (request, response) { app.post("/savesettings", jsonParser, function (request, response) {
writeFileAtomic('public/settings.json', JSON.stringify(request.body, null, 4), 'utf8', function (err) { try {
if (err) { writeFileAtomicSync('public/settings.json', JSON.stringify(request.body, null, 4), 'utf8');
response.send(err); response.send({ result: "ok" });
console.log(err); } catch (err) {
} else { console.log(err);
response.send({ result: "ok" }); response.send(err);
} }
});
}); });
function getCharaCardV2(jsonObject) { function getCharaCardV2(jsonObject) {
@@ -2419,13 +2415,17 @@ app.post("/importchat", urlencodedParser, function (request, response) {
}); });
const errors = []; const errors = [];
newChats.forEach(chat => writeFileAtomic(
`${chatsPath + avatar_url}/${ch_name} - ${humanizedISO8601DateTime()} imported.jsonl`, for (const chat of newChats) {
chat.map(tryParse).filter(x => x).join('\n'), const filePath = `${chatsPath + avatar_url}/${ch_name} - ${humanizedISO8601DateTime()} imported.jsonl`;
'utf8', const fileContent = chat.map(tryParse).filter(x => x).join('\n');
(err) => err ?? errors.push(err)
) try {
); writeFileAtomicSync(filePath, fileContent, 'utf8');
} catch (err) {
errors.push(err);
}
}
if (0 < errors.length) { if (0 < errors.length) {
response.send('Errors occurred while writing character files. Errors: ' + JSON.stringify(errors)); response.send('Errors occurred while writing character files. Errors: ' + JSON.stringify(errors));
@@ -3649,7 +3649,8 @@ const setupTasks = async function () {
console.log('Launching...'); console.log('Launching...');
if (autorun) open(autorunUrl.toString()); if (autorun) open(autorunUrl.toString());
console.log('SillyTavern is listening on: ' + tavernUrl);
console.log('\x1b[32mSillyTavern is listening on: ' + tavernUrl + '\x1b[0m');
if (listen) { if (listen) {
console.log('\n0.0.0.0 means SillyTavern is listening on all network interfaces (Wi-Fi, LAN, localhost). If you want to limit it only to internal localhost (127.0.0.1), change the setting in config.conf to “listen=false”\n'); console.log('\n0.0.0.0 means SillyTavern is listening on all network interfaces (Wi-Fi, LAN, localhost). If you want to limit it only to internal localhost (127.0.0.1), change the setting in config.conf to “listen=false”\n');