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
7 changed files with 66 additions and 39 deletions

View File

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

View File

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

View File

@@ -48,8 +48,10 @@ function downloadAssetsList(url) {
} }
console.debug(DEBUG_PREFIX, "Updated available assets to", availableAssets); 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" }); let assetTypeMenu = $('<div />', { id: "assets_audio_ambient_div", class: "assets-list-div" });
assetTypeMenu.append(`<h3>${assetType}</h3>`) assetTypeMenu.append(`<h3>${assetType}</h3>`)
for (const i in availableAssets[assetType]) { for (const i in availableAssets[assetType]) {

View File

@@ -13,6 +13,10 @@
padding: 5px; padding: 5px;
} }
.assets-list-div h3 {
text-transform: capitalize;
}
.assets-list-div i { .assets-list-div i {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@@ -26,6 +30,10 @@
margin-left: 10px; margin-left: 10px;
} }
.assets-list-div i span:first-of-type {
font-weight: bold;
}
.asset-download-button { .asset-download-button {
position: relative; position: relative;
width: 50px; width: 50px;

View File

@@ -1,7 +1,7 @@
<div id="assets_ui"> <div id="assets_ui">
<div class="inline-drawer"> <div class="inline-drawer">
<div class="inline-drawer-toggle inline-drawer-header"> <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 class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
</div> </div>
<div class="inline-drawer-content"> <div class="inline-drawer-content">

View File

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

View File

@@ -1360,6 +1360,12 @@ app.post("/getcharacters", jsonParser, function (request, response) {
let processingPromises = pngFiles.map((file, index) => processCharacter(file, index)); let processingPromises = pngFiles.map((file, index) => processCharacter(file, index));
await Promise.all(processingPromises); performance.mark('B'); 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)); response.send(JSON.stringify(characters));
}); });
}); });