Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging

This commit is contained in:
RossAscends 2023-10-10 04:49:37 +09:00
commit 575e21a1f5
7 changed files with 66 additions and 39 deletions

View File

@ -103,39 +103,39 @@ input.extension_missing[type="checkbox"] {
}
/** LEFT COLUMN **/
#extensions_settings>.expression_settings {
#extensions_settings>#assets_ui {
order: 1;
}
#extensions_settings>.background_settings {
#extensions_settings>.expression_settings {
order: 2;
}
#extensions_settings>.sd_settings {
#extensions_settings>.background_settings {
order: 3;
}
#extensions_settings>#tts_settings {
#extensions_settings>.sd_settings {
order: 4;
}
#extensions_settings>#rvc_settings {
#extensions_settings>#tts_settings {
order: 5;
}
#extensions_settings>.objective-settings {
#extensions_settings>#rvc_settings {
order: 6;
}
#extensions_settings>#speech_recognition_settings {
#extensions_settings>.objective-settings {
order: 7;
}
#extensions_settings>#audio_settings {
#extensions_settings>#speech_recognition_settings {
order: 8;
}
#extensions_settings>#assets_ui {
#extensions_settings>#audio_settings {
order: 9;
}

View File

@ -251,6 +251,8 @@ export {
extension_prompt_types,
mesForShowdownParse,
printCharacters,
isOdd,
countOccurrences
}
// Allow target="_blank" in links
@ -3497,9 +3499,10 @@ export async function sendMessageAsUser(textareaText, messageBias) {
}
statMesProcess(chat[chat.length - 1], 'user', characters, this_chid, '');
// Wait for all handlers to finish before continuing with the prompt
await eventSource.emit(event_types.MESSAGE_SENT, (chat.length - 1));
addOneMessage(chat[chat.length - 1]);
await eventSource.emit(event_types.USER_MESSAGE_RENDERED, (chat.length - 1));
const chat_id = (chat.length - 1);
await eventSource.emit(event_types.MESSAGE_SENT, chat_id);
addOneMessage(chat[chat_id]);
await eventSource.emit(event_types.USER_MESSAGE_RENDERED, chat_id);
console.debug('message sent as user');
}
@ -4005,9 +4008,10 @@ async function saveReply(type, getMessage, _, title) {
if (power_user.message_token_count_enabled) {
chat[chat.length - 1]['extra']['token_count'] = getTokenCount(chat[chat.length - 1]['mes'], 0);
}
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
addOneMessage(chat[chat.length - 1], { type: 'swipe' });
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1));
const chat_id = (chat.length - 1);
await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id);
addOneMessage(chat[chat_id], { type: 'swipe' });
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id);
} else {
chat[chat.length - 1]['mes'] = getMessage;
}
@ -4024,9 +4028,10 @@ async function saveReply(type, getMessage, _, title) {
if (power_user.message_token_count_enabled) {
chat[chat.length - 1]['extra']['token_count'] = getTokenCount(chat[chat.length - 1]['mes'], 0);
}
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
addOneMessage(chat[chat.length - 1], { type: 'swipe' });
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1));
const chat_id = (chat.length - 1);
await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id);
addOneMessage(chat[chat_id], { type: 'swipe' });
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id);
} else if (type === 'appendFinal') {
oldMessage = chat[chat.length - 1]['mes'];
console.debug("Trying to appendFinal.")
@ -4040,9 +4045,10 @@ async function saveReply(type, getMessage, _, title) {
if (power_user.message_token_count_enabled) {
chat[chat.length - 1]['extra']['token_count'] = getTokenCount(chat[chat.length - 1]['mes'], 0);
}
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
addOneMessage(chat[chat.length - 1], { type: 'swipe' });
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1));
const chat_id = (chat.length - 1);
await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id);
addOneMessage(chat[chat_id], { type: 'swipe' });
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id);
} else {
console.debug('entering chat update routine for non-swipe post');
@ -4077,9 +4083,10 @@ async function saveReply(type, getMessage, _, title) {
}
saveImageToMessage(img, chat[chat.length - 1]);
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
addOneMessage(chat[chat.length - 1]);
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1));
const chat_id = (chat.length - 1);
await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id);
addOneMessage(chat[chat_id]);
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id);
}
const item = chat[chat.length - 1];
@ -4545,8 +4552,9 @@ async function getChatResult() {
await eventSource.emit(event_types.CHAT_CHANGED, (getCurrentChatId()));
if (chat.length === 1) {
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1));
const chat_id = (chat.length - 1);
await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id);
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id);
}
}
@ -6409,10 +6417,11 @@ async function createOrEditCharacter(e) {
const firstMessage = getFirstMessage();
chat[0] = firstMessage;
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
const chat_id = (chat.length - 1);
await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id);
clearChat();
await printMessages();
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, (chat.length - 1));
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id);
await saveChatConditional();
}
},

View File

@ -48,8 +48,10 @@ function downloadAssetsList(url) {
}
console.debug(DEBUG_PREFIX, "Updated available assets to", availableAssets);
// First extensions, then everything else
const assetTypes = Object.keys(availableAssets).sort((a, b) => (a === 'extension') ? -1 : (b === 'extension') ? 1 : 0);
for (const assetType in availableAssets) {
for (const assetType of assetTypes) {
let assetTypeMenu = $('<div />', { id: "assets_audio_ambient_div", class: "assets-list-div" });
assetTypeMenu.append(`<h3>${assetType}</h3>`)
for (const i in availableAssets[assetType]) {

View File

@ -13,6 +13,10 @@
padding: 5px;
}
.assets-list-div h3 {
text-transform: capitalize;
}
.assets-list-div i {
display: flex;
flex-direction: row;
@ -22,10 +26,14 @@
font-style: normal;
}
.assets-list-div i span{
.assets-list-div i span {
margin-left: 10px;
}
.assets-list-div i span:first-of-type {
font-weight: bold;
}
.asset-download-button {
position: relative;
width: 50px;
@ -34,7 +42,7 @@
outline: none;
border-radius: 2px;
cursor: pointer;
}
}
.asset-download-button:active {
background: #007a63;
@ -68,11 +76,11 @@
}
@keyframes asset-download-button-loading-spinner {
from {
transform: rotate(0turn);
}
from {
transform: rotate(0turn);
}
to {
transform: rotate(1turn);
}
to {
transform: rotate(1turn);
}
}

View File

@ -1,7 +1,7 @@
<div id="assets_ui">
<div class="inline-drawer">
<div class="inline-drawer-toggle inline-drawer-header">
<b>Assets</b>
<b>Download Extensions & Assets</b>
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
</div>
<div class="inline-drawer-content">

View File

@ -1,3 +1,5 @@
export {translate};
import {
callPopup,
eventSource,
@ -11,7 +13,7 @@ import {
import { extension_settings, getContext } from "../../extensions.js";
import { secret_state, writeSecret } from "../../secrets.js";
const autoModeOptions = {
export const autoModeOptions = {
NONE: 'none',
RESPONSES: 'responses',
INPUT: 'inputs',

View File

@ -1360,6 +1360,12 @@ app.post("/getcharacters", jsonParser, function (request, response) {
let processingPromises = pngFiles.map((file, index) => processCharacter(file, index));
await Promise.all(processingPromises); performance.mark('B');
// Filter out invalid/broken characters
characters = Object.values(characters).filter(x => x?.name).reduce((acc, val, index) => {
acc[index] = val;
return acc;
}, {});
response.send(JSON.stringify(characters));
});
});