Merge branch 'SillyTavern:staging' into staging
This commit is contained in:
commit
6bedc36611
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"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": "***",
|
||||
"example_separator": "***"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"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>",
|
||||
"example_separator": "<START>"
|
||||
}
|
||||
|
|
|
@ -208,8 +208,7 @@
|
|||
<div class="range-block-title justifyLeft">
|
||||
AI Module
|
||||
</div>
|
||||
<div class="toggle-description justifyLeft"
|
||||
data-i18n="Changes the style of the generated text.">
|
||||
<div class="toggle-description justifyLeft" data-i18n="Changes the style of the generated text.">
|
||||
Changes the style of the generated text.
|
||||
</div>
|
||||
<select id="nai_prefix">
|
||||
|
@ -937,7 +936,7 @@
|
|||
<span data-i18n="Negative Prompt">Negative Prompt</span>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
<div class="toggle-description justifyLeft"
|
||||
data-i18n="Prompt that is used when the NSFW toggle is O">
|
||||
<div class="toggle-description justifyLeft" data-i18n="Prompt that is used when the NSFW toggle is O">
|
||||
Prompt that is used when the NSFW toggle is OFF
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
|
@ -1494,9 +1492,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<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.">
|
||||
Set at the beginning of the chat history to indicate that a new chat is about to start.
|
||||
</span>
|
||||
<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.
|
||||
</span>
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<textarea id="newchat_prompt_textarea" class="text_pole textarea_compact" name="new_chat" rows="3" placeholder=""></textarea>
|
||||
|
@ -1510,9 +1508,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<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.">
|
||||
Set at the beginning of the chat history to indicate that a new group chat is about to start.
|
||||
</span>
|
||||
<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.
|
||||
</span>
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<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 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.">
|
||||
Set at the beginning of Dialogue examples to indicate that a new example chat is about to start.
|
||||
</span>
|
||||
<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.
|
||||
</span>
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<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 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.">
|
||||
Set at the end of the chat history when the continue button is pressed.
|
||||
</span>
|
||||
<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.
|
||||
</span>
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<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
|
||||
</div>
|
||||
<div class="toggle-description justifyLeft">
|
||||
<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.
|
||||
</span>
|
||||
<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.
|
||||
</span>
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<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">
|
||||
<h2></h2>
|
||||
</div>
|
||||
<i id="hideCharPanelAvatarButton" class="fa-solid fa-eye menu_button"></i>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 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">
|
||||
</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."> </div>
|
||||
|
||||
|
||||
<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">
|
||||
|
@ -3077,6 +3076,7 @@
|
|||
|
||||
<div id="description_div" class="marginBot5">
|
||||
<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."> </div>
|
||||
<a href="https://docs.sillytavern.app/usage/core-concepts/characterdesign/#character-description" class="notes-link" target="_blank">
|
||||
<span class="note-link-span">?</span>
|
||||
</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_value text_pole" type="number" min="-100" value="0" max="100" />
|
||||
<i class="menu_button fa-solid fa-xmark openai_logit_bias_remove"></i>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="novelai_logit_bias_template" class="template_element">
|
||||
<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>
|
||||
</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_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>
|
||||
|
@ -4286,4 +4286,4 @@
|
|||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
|
@ -2442,9 +2442,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||
mesExamples = '';
|
||||
}
|
||||
|
||||
// OpenAI handler always expects it
|
||||
const blockHeading = main_api === 'openai' ? '<START>' : (power_user.context.example_separator || '');
|
||||
let mesExamplesArray = mesExamples.split(/<START>/gi).slice(1).map(block => `${blockHeading}\n${block.trim()}\n`);
|
||||
const exampleSeparator = power_user.context.example_separator ? `${power_user.context.example_separator}\n` : '';
|
||||
const blockHeading = main_api === 'openai' ? '<START>\n' : exampleSeparator;
|
||||
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
|
||||
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) {
|
||||
|
||||
|
@ -4452,7 +4452,7 @@ async function getChat() {
|
|||
}
|
||||
await getChatResult();
|
||||
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 () {
|
||||
|
@ -6591,7 +6591,7 @@ async function createOrEditCharacter(e) {
|
|||
);
|
||||
$("#create_button").attr("value", "Save");
|
||||
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) {
|
||||
$("#create_button").removeAttr("disabled");
|
||||
|
@ -7643,7 +7643,7 @@ $(document).ready(function () {
|
|||
if (popup_type == "del_ch") {
|
||||
const deleteChats = !!$("#del_char_checkbox").prop("checked");
|
||||
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") {
|
||||
createOrEditCharacter();
|
||||
|
@ -9144,4 +9144,9 @@ $(document).ready(function () {
|
|||
$("#charListGridToggle").on('click', async () => {
|
||||
doCharListDisplaySwitch();
|
||||
});
|
||||
|
||||
$("#hideCharPanelAvatarButton").on('click', () => {
|
||||
$('#avatar-and-name-block').slideToggle()
|
||||
})
|
||||
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import {callPopup, event_types, eventSource, is_send_press, main_api, substitute
|
|||
import { is_group_generating } from "./group-chats.js";
|
||||
import {TokenHandler} from "./openai.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) {
|
||||
let timeoutId;
|
||||
|
@ -1511,6 +1511,7 @@ PromptManagerModule.prototype.getFormattedDate = function() {
|
|||
*/
|
||||
PromptManagerModule.prototype.makeDraggable = function () {
|
||||
$(`#${this.configuration.prefix}prompt_manager_list`).sortable({
|
||||
delay: getSortableDelay(),
|
||||
items: `.${this.configuration.prefix}prompt_manager_prompt_draggable`,
|
||||
update: ( event, ui ) => {
|
||||
const promptOrder = this.getPromptOrderForCharacter(this.activeCharacter);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
z-index: 2;
|
||||
overflow: hidden;
|
||||
resize: both;
|
||||
|
||||
display: flex;
|
||||
}
|
||||
|
||||
img.expression {
|
||||
|
@ -56,7 +56,6 @@ img.expression {
|
|||
min-height: 100px;
|
||||
max-height: 90vh;
|
||||
max-width: 90vh;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
padding: 0;
|
||||
|
@ -181,4 +180,4 @@ img.expression.default {
|
|||
div.expression {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 { uuidv4, waitUntilCondition } from "../../utils.js";
|
||||
import { getSortableDelay, uuidv4 } from "../../utils.js";
|
||||
import { regex_placement } from "./engine.js";
|
||||
|
||||
async function saveRegexScript(regexScript, existingScriptIndex) {
|
||||
|
@ -236,6 +236,7 @@ jQuery(async () => {
|
|||
});
|
||||
|
||||
$('#saved_regex_scripts').sortable({
|
||||
delay: getSortableDelay(),
|
||||
stop: function () {
|
||||
let newScripts = [];
|
||||
$('#saved_regex_scripts').children().each(function () {
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
import {
|
||||
power_user,
|
||||
} from "./power-user.js";
|
||||
import { getSortableDelay } from "./utils.js";
|
||||
|
||||
export {
|
||||
kai_settings,
|
||||
|
@ -243,7 +244,7 @@ function sortItemsByOrder(orderArray) {
|
|||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
jQuery(function () {
|
||||
sliders.forEach(slider => {
|
||||
$(document).on("input", slider.sliderId, function () {
|
||||
const value = $(this).val();
|
||||
|
@ -267,6 +268,7 @@ $(document).ready(function () {
|
|||
});
|
||||
|
||||
$('#kobold_order').sortable({
|
||||
delay: getSortableDelay(),
|
||||
stop: function () {
|
||||
const order = [];
|
||||
$('#kobold_order').children().each(function () {
|
||||
|
|
|
@ -10,8 +10,9 @@ import {
|
|||
import { getCfg } from "./extensions/cfg/util.js";
|
||||
import { MAX_CONTEXT_DEFAULT, tokenizers } from "./power-user.js";
|
||||
import {
|
||||
getSortableDelay,
|
||||
getStringHash,
|
||||
uuidv4
|
||||
uuidv4,
|
||||
} from "./utils.js";
|
||||
|
||||
export {
|
||||
|
@ -47,7 +48,7 @@ const nai_settings = {
|
|||
model_novel: "clio-v1",
|
||||
preset_settings_novel: "Talker-Chat-Clio",
|
||||
streaming_novel: false,
|
||||
nai_preamble: default_preamble,
|
||||
preamble: default_preamble,
|
||||
prefix: '',
|
||||
cfg_uc: '',
|
||||
banned_tokens: '',
|
||||
|
@ -120,6 +121,7 @@ function loadNovelPreset(preset) {
|
|||
nai_settings.banned_tokens = preset.banned_tokens || '';
|
||||
nai_settings.order = preset.order || default_order;
|
||||
nai_settings.logit_bias = preset.logit_bias || [];
|
||||
nai_settings.preamble = preset.preamble || default_preamble;
|
||||
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').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.temperature = settings.temperature;
|
||||
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_counter_novel").text(Number(ui_settings.repetition_penalty).toFixed(2));
|
||||
$("#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_slope_novel").val(ui_settings.repetition_penalty_slope);
|
||||
$("#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));
|
||||
$("#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_preamble_textarea').val(ui_settings.preamble);
|
||||
$('#nai_prefix').val(ui_settings.prefix || "vanilla");
|
||||
$('#nai_cfg_uc').val(ui_settings.cfg_uc || "");
|
||||
$('#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,
|
||||
"prefix": prefix,
|
||||
"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) {
|
||||
generate_data.streaming = nai_settings.streaming_novel;
|
||||
|
||||
const response = await fetch('/generate_novelai', {
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify(generate_data),
|
||||
|
@ -637,7 +644,7 @@ $("#nai_preamble_restore").on('click', function () {
|
|||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
jQuery(function () {
|
||||
sliders.forEach(slider => {
|
||||
$(document).on("input", slider.sliderId, function () {
|
||||
const value = $(this).val();
|
||||
|
@ -676,6 +683,7 @@ $(document).ready(function () {
|
|||
});
|
||||
|
||||
$('#novel_order').sortable({
|
||||
delay: getSortableDelay(),
|
||||
stop: saveSamplingOrder,
|
||||
});
|
||||
|
||||
|
|
|
@ -46,9 +46,9 @@ export {
|
|||
export const MAX_CONTEXT_DEFAULT = 4096;
|
||||
const MAX_CONTEXT_UNLOCKED = 65536;
|
||||
|
||||
const defaultStoryString = `{{#if description}}{{{description}}}{{/if}}
|
||||
{{#if personality}}{{{personality}}}{{/if}}
|
||||
{{#if scenario}}Scenario: {{{scenario}}}{{/if}}`;
|
||||
const defaultStoryString = `{{#if description}}{{description}}{{/if}}
|
||||
{{#if personality}}{{personality}}{{/if}}
|
||||
{{#if scenario}}Scenario: {{scenario}}{{/if}}`;
|
||||
const defaultExampleSeparator = '***';
|
||||
const defaultChatStart = '***';
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ export function fuzzySearchGroups(searchValue) {
|
|||
|
||||
export function renderStoryString(params) {
|
||||
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);
|
||||
output = substituteParams(output, params.user, params.char);
|
||||
output = `${output.trim()}\n`; // add a newline to the end
|
||||
|
|
|
@ -229,7 +229,6 @@ class PresetManager {
|
|||
'streaming_novel',
|
||||
'nai_preamble',
|
||||
'model_novel',
|
||||
'preamble',
|
||||
];
|
||||
const settings = Object.assign({}, getSettingsByApiId(this.apiId));
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@ export function isDigitsOnly(str) {
|
|||
return /^\d+$/.test(str);
|
||||
}
|
||||
|
||||
// Increase delay on touch screens
|
||||
export function getSortableDelay() {
|
||||
return navigator.maxTouchPoints > 0 ? 750 : 100;
|
||||
}
|
||||
|
||||
export function shuffle(array) {
|
||||
let currentIndex = array.length,
|
||||
randomIndex;
|
||||
|
|
|
@ -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 { 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 { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js";
|
||||
import { registerSlashCommand } from "./slash-commands.js";
|
||||
|
@ -302,6 +302,7 @@ function displayWorldEntries(name, data) {
|
|||
}
|
||||
|
||||
$("#world_popup_entries_list").sortable({
|
||||
delay: getSortableDelay(),
|
||||
handle: ".drag-handle",
|
||||
stop: async function (event, ui) {
|
||||
$('#world_popup_entries_list .world_entry').each(function (index) {
|
||||
|
@ -1129,7 +1130,7 @@ function matchKeys(haystack, needle) {
|
|||
return haystack.includes(transformedString);
|
||||
}
|
||||
else {
|
||||
const regex = new RegExp(`\\b${transformedString}\\b`);
|
||||
const regex = new RegExp(`\\b${escapeRegex(transformedString)}\\b`);
|
||||
if (regex.test(haystack)) {
|
||||
return true;
|
||||
}
|
||||
|
|
57
server.js
57
server.js
|
@ -69,7 +69,6 @@ app.use(responseTime());
|
|||
|
||||
const fs = require('fs');
|
||||
const writeFileAtomicSync = require('write-file-atomic').sync;
|
||||
const writeFileAtomic = require('write-file-atomic');
|
||||
const readline = require('readline');
|
||||
const open = require('open');
|
||||
|
||||
|
@ -1446,18 +1445,16 @@ app.post('/deleteuseravatar', jsonParser, function (request, response) {
|
|||
});
|
||||
|
||||
app.post("/setbackground", jsonParser, function (request, response) {
|
||||
var bg = "#bg1 {background-image: url('../backgrounds/" + request.body.bg + "');}";
|
||||
writeFileAtomic('public/css/bg_load.css', bg, 'utf8', function (err) {
|
||||
if (err) {
|
||||
response.send(err);
|
||||
return console.log(err);
|
||||
} else {
|
||||
//response.redirect("/");
|
||||
response.send({ result: 'ok' });
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
const bg = `#bg1 {background-image: url('../backgrounds/${request.body.bg}');}`;
|
||||
writeFileAtomicSync('public/css/bg_load.css', bg, 'utf8');
|
||||
response.send({ result: 'ok' });
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
response.send(err);
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/delbackground", jsonParser, function (request, response) {
|
||||
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) {
|
||||
writeFileAtomic('public/settings.json', JSON.stringify(request.body, null, 4), 'utf8', function (err) {
|
||||
if (err) {
|
||||
response.send(err);
|
||||
console.log(err);
|
||||
} else {
|
||||
response.send({ result: "ok" });
|
||||
}
|
||||
});
|
||||
try {
|
||||
writeFileAtomicSync('public/settings.json', JSON.stringify(request.body, null, 4), 'utf8');
|
||||
response.send({ result: "ok" });
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
response.send(err);
|
||||
}
|
||||
});
|
||||
|
||||
function getCharaCardV2(jsonObject) {
|
||||
|
@ -2419,13 +2415,17 @@ app.post("/importchat", urlencodedParser, function (request, response) {
|
|||
});
|
||||
|
||||
const errors = [];
|
||||
newChats.forEach(chat => writeFileAtomic(
|
||||
`${chatsPath + avatar_url}/${ch_name} - ${humanizedISO8601DateTime()} imported.jsonl`,
|
||||
chat.map(tryParse).filter(x => x).join('\n'),
|
||||
'utf8',
|
||||
(err) => err ?? errors.push(err)
|
||||
)
|
||||
);
|
||||
|
||||
for (const chat of newChats) {
|
||||
const filePath = `${chatsPath + avatar_url}/${ch_name} - ${humanizedISO8601DateTime()} imported.jsonl`;
|
||||
const fileContent = chat.map(tryParse).filter(x => x).join('\n');
|
||||
|
||||
try {
|
||||
writeFileAtomicSync(filePath, fileContent, 'utf8');
|
||||
} catch (err) {
|
||||
errors.push(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < errors.length) {
|
||||
response.send('Errors occurred while writing character files. Errors: ' + JSON.stringify(errors));
|
||||
|
@ -3649,7 +3649,8 @@ const setupTasks = async function () {
|
|||
console.log('Launching...');
|
||||
|
||||
if (autorun) open(autorunUrl.toString());
|
||||
console.log('SillyTavern is listening on: ' + tavernUrl);
|
||||
|
||||
console.log('\x1b[32mSillyTavern is listening on: ' + tavernUrl + '\x1b[0m');
|
||||
|
||||
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');
|
||||
|
|
Loading…
Reference in New Issue