Save chat id between received and rendered event for safety (blip extension allow multiple message received before one is rendered). Added export in translate extension for usage in blip extension.
This commit is contained in:
parent
b3cdfe4fdf
commit
df4ca46c02
|
@ -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,10 @@ 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);
|
||||
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();
|
||||
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();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue