Skip to content

Commit

Permalink
Merge branch 'SillyTavern:release' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
teralomaniac authored Nov 13, 2023
2 parents 2f669ff + 7bf62b3 commit cabb9a3
Show file tree
Hide file tree
Showing 22 changed files with 1,064 additions and 325 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"type": "git",
"url": "https://github.com/SillyTavern/SillyTavern.git"
},
"version": "1.10.8",
"version": "1.10.9",
"scripts": {
"start": "node server.js",
"start-multi": "node server.js --disableCsrf",
Expand Down
8 changes: 8 additions & 0 deletions public/css/st-tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@
display: flex;
}

.flexBasis100p {
flex-basis: 100%;
}

.flexBasis50p {
flex-basis: 50%
}
Expand Down Expand Up @@ -263,6 +267,10 @@
flex-shrink: 1
}

.flexWrap {
flex-wrap: wrap;
}

.flexnowrap {
flex-wrap: nowrap;
}
Expand Down
8 changes: 8 additions & 0 deletions public/css/toggle-dependent.css
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,11 @@ body.expandMessageActions .mes .mes_buttons .extraMesButtons {
body.expandMessageActions .mes .mes_buttons .extraMesButtonsHint {
display: none !important;
}

#openai_image_inlining:not(:checked) ~ #image_inlining_hint {
display: none;
}

#openai_image_inlining:checked ~ #image_inlining_hint {
display: block;
}
170 changes: 111 additions & 59 deletions public/index.html

Large diffs are not rendered by default.

111 changes: 49 additions & 62 deletions public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ import {
escapeRegex,
resetScrollHeight,
onlyUnique,
getBase64Async,
} from "./scripts/utils.js";

import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, processExtensionHelpers, registerExtensionHelper, renderExtensionTemplate, runGenerationInterceptors, saveMetadataDebounced } from "./scripts/extensions.js";
Expand Down Expand Up @@ -184,7 +185,7 @@ import {
} from "./scripts/instruct-mode.js";
import { applyLocale } from "./scripts/i18n.js";
import { getFriendlyTokenizerName, getTokenCount, getTokenizerModel, initTokenizers, saveTokenCache } from "./scripts/tokenizers.js";
import { initPersonas, selectCurrentPersona, setPersonaDescription } from "./scripts/personas.js";
import { createPersona, initPersonas, selectCurrentPersona, setPersonaDescription } from "./scripts/personas.js";
import { getBackgrounds, initBackgrounds } from "./scripts/backgrounds.js";
import { hideLoader, showLoader } from "./scripts/loader.js";
import { CharacterContextMenu, BulkEditOverlay } from "./scripts/BulkEditOverlay.js";
Expand Down Expand Up @@ -313,11 +314,6 @@ export const event_types = {

export const eventSource = new EventEmitter();

// Check for override warnings every 5 seconds...
setInterval(displayOverrideWarnings, 5000);
// ...or when the chat changes
eventSource.on(event_types.SETTINGS_LOADED, () => { settingsReady = true; });
eventSource.on(event_types.CHAT_CHANGED, displayOverrideWarnings);
eventSource.on(event_types.MESSAGE_RECEIVED, processExtensionHelpers);
eventSource.on(event_types.MESSAGE_SENT, processExtensionHelpers);

Expand Down Expand Up @@ -729,7 +725,7 @@ async function firstLoadInit() {
sendSystemMessage(system_message_types.WELCOME);
await readSecretState();
await getClientVersion();
await getSettings("def");
await getSettings();
await getUserAvatars();
await getCharacters();
await getBackgrounds();
Expand Down Expand Up @@ -926,12 +922,12 @@ async function getStatus() {

export function startStatusLoading() {
$(".api_loading").show();
$(".api_button").attr("disabled", "disabled").addClass("disabled");
$(".api_button").addClass("disabled");
}

export function stopStatusLoading() {
$(".api_loading").hide();
$(".api_button").removeAttr("disabled").removeClass("disabled");
$(".api_button").removeClass("disabled");
}

export function resultCheckStatus() {
Expand Down Expand Up @@ -1014,7 +1010,7 @@ function getBackBlock() {
function getEmptyBlock() {
const icons = ['fa-dragon', 'fa-otter', 'fa-kiwi-bird', 'fa-crow', 'fa-frog'];
const texts = ['Here be dragons', 'Otterly empty', 'Kiwibunga', 'Pump-a-Rum', 'Croak it'];
const roll = Math.floor(Math.random() * icons.length);
const roll = new Date().getMinutes() % icons.length;
const emptyBlock = `
<div class="empty_block">
<i class="fa-solid ${icons[roll]} fa-4x"></i>
Expand Down Expand Up @@ -1050,9 +1046,10 @@ function getCharacterBlock(item, id) {
template.find('.ch_description').hide();
}

const version = item.data?.character_version || '';
if (version) {
template.find('.character_version').text(version);
const auxFieldName = power_user.aux_field || 'character_version';
const auxFieldValue = (item.data && item.data[auxFieldName]) || '';
if (auxFieldValue) {
template.find('.character_version').text(auxFieldValue);
}
else {
template.find('.character_version').hide();
Expand All @@ -1079,7 +1076,6 @@ async function printCharacters(fullRefresh = false) {
}

await delay(1);
displayOverrideWarnings();
}

const storageKey = 'Characters_PerPage';
Expand Down Expand Up @@ -3408,7 +3404,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
generate_data = getNovelGenerationData(finalPrompt, presetSettings, maxLength, isImpersonate, cfgValues);
}
else if (main_api == 'openai') {
let [prompt, counts] = prepareOpenAIMessages({
let [prompt, counts] = await prepareOpenAIMessages({
name2: name2,
charDescription: description,
charPersonality: personality,
Expand Down Expand Up @@ -4784,22 +4780,21 @@ async function read_avatar_load(input) {
create_save.avatar = input.files;
}

const e = await new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = resolve;
reader.onerror = reject;
reader.readAsDataURL(input.files[0]);
})
const file = input.files[0];
const fileData = await getBase64Async(file);

$('#dialogue_popup').addClass('large_dialogue_popup wide_dialogue_popup');
if (!power_user.never_resize_avatars) {
$('#dialogue_popup').addClass('large_dialogue_popup wide_dialogue_popup');
const croppedImage = await callPopup(getCropPopup(fileData), 'avatarToCrop');
if (!croppedImage) {
return;
}

const croppedImage = await callPopup(getCropPopup(e.target.result), 'avatarToCrop');
if (!croppedImage) {
return;
$("#avatar_load_preview").attr("src", croppedImage);
} else {
$("#avatar_load_preview").attr("src", fileData);
}

$("#avatar_load_preview").attr("src", croppedImage || e.target.result);

if (menu_type == "create") {
return;
}
Expand Down Expand Up @@ -5161,24 +5156,19 @@ async function uploadUserAvatar(e) {
}

const formData = new FormData($("#form_upload_avatar").get(0));

const dataUrl = await new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = resolve;
reader.onerror = reject;
reader.readAsDataURL(file);
});

$('#dialogue_popup').addClass('large_dialogue_popup wide_dialogue_popup');
const confirmation = await callPopup(getCropPopup(dataUrl.target.result), 'avatarToCrop');
if (!confirmation) {
return;
}

const dataUrl = await getBase64Async(file);
let url = "/uploaduseravatar";

if (crop_data !== undefined) {
url += `?crop=${encodeURIComponent(JSON.stringify(crop_data))}`;
if (!power_user.never_resize_avatars) {
$('#dialogue_popup').addClass('large_dialogue_popup wide_dialogue_popup');
const confirmation = await callPopup(getCropPopup(dataUrl), 'avatarToCrop');
if (!confirmation) {
return;
}

if (crop_data !== undefined) {
url += `?crop=${encodeURIComponent(JSON.stringify(crop_data))}`;
}
}

jQuery.ajax({
Expand All @@ -5189,14 +5179,20 @@ async function uploadUserAvatar(e) {
cache: false,
contentType: false,
processData: false,
success: async function () {
success: async function (data) {
// If the user uploaded a new avatar, we want to make sure it's not cached
const name = formData.get("overwrite_name");
if (name) {
await fetch(getUserAvatar(name), { cache: "no-cache" });
reloadUserAvatar(true);
}

if (data.path) {
await getUserAvatars();
await delay(500);
await createPersona(data.path);
}

crop_data = undefined;
await getUserAvatars();
},
Expand Down Expand Up @@ -5234,7 +5230,7 @@ async function doOnboarding(avatarId) {

//***************SETTINGS****************//
///////////////////////////////////////////
async function getSettings(type) {
async function getSettings() {
const response = await fetch("/getsettings", {
method: "POST",
headers: getRequestHeaders(),
Expand Down Expand Up @@ -5407,6 +5403,7 @@ async function getSettings(type) {
}
}

settingsReady = true;
eventSource.emit(event_types.SETTINGS_LOADED);
}

Expand Down Expand Up @@ -7131,19 +7128,6 @@ const swipe_right = () => {
}
}



function displayOverrideWarnings() {
if (!this_chid || !selected_group) {
$('.prompt_overridden').hide();
$('.jailbreak_overridden').hide();
return;
}

$('.prompt_overridden').toggle(!!(characters[this_chid]?.data?.system_prompt));
$('.jailbreak_overridden').toggle(!!(characters[this_chid]?.data?.post_history_instructions));
}

function connectAPISlash(_, text) {
if (!text) return;

Expand Down Expand Up @@ -8694,7 +8678,7 @@ jQuery(async function () {

startStatusLoading();
// Check near immediately rather than waiting for up to 90s
setTimeout(getStatusNovel, 10);
await getStatusNovel();
});

//**************************CHARACTER IMPORT EXPORT*************************//
Expand Down Expand Up @@ -9104,8 +9088,11 @@ jQuery(async function () {
}
});

let manualInputTimeout;

$(document).on('input', '.range-block-counter input, .neo-range-input', function () {
setTimeout(() => {
clearTimeout(manualInputTimeout);
manualInputTimeout = setTimeout(() => {
const caretPosition = saveCaretPosition($(this).get(0));
const myText = $(this).val().trim();
$(this).val(myText); // trim line breaks and spaces
Expand All @@ -9127,7 +9114,7 @@ jQuery(async function () {

//yolo anything for Lab Mode
if (power_user.enableLabMode) {
console.log($(masterElement).attr('id'), myValue)
//console.log($(masterElement).attr('id'), myValue)
$(masterElement).val(myValue).trigger('input')
return
}
Expand Down Expand Up @@ -9171,7 +9158,7 @@ jQuery(async function () {

restoreCaretPosition($(this).get(0), caretPosition);
}, 2000);
})
});

$(".user_stats_button").on('click', function () {
userStatsHandler();
Expand Down
4 changes: 4 additions & 0 deletions public/scripts/BulkEditOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "../script.js";

import { favsToHotswap } from "./RossAscends-mods.js";
import { hideLoader, showLoader } from "./loader.js";
import { convertCharacterToPersona } from "./personas.js";
import { createTagInput, getTagKeyForCharacter, tag_map } from "./tags.js";

Expand Down Expand Up @@ -614,9 +615,12 @@ class BulkEditOverlay {

const deleteChats = document.getElementById('del_char_checkbox').checked ?? false;

showLoader();
toastr.info("We're deleting your characters, please wait...", 'Working on it');
Promise.all(this.selectedCharacters.map(async characterId => CharacterContextMenu.delete(characterId, deleteChats)))
.then(() => getCharacters())
.then(() => this.browseState())
.finally(() => hideLoader());
}
);
}
Expand Down
Loading

0 comments on commit cabb9a3

Please sign in to comment.