mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #1224 from Tony-sama/staging
Minor safety changes to handle blip extension
This commit is contained in:
@@ -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,10 @@ 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);
|
||||||
|
addOneMessage(chat[chat_id]);
|
||||||
|
await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6409,10 +6418,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();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -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',
|
||||||
|
Reference in New Issue
Block a user