Fix duplicate CHARACTER_MESSAGE_RENDERED events during streaming (#4584) Refer to line 5771, where is correct, but the branch is not added, resulting in the branch being triggered once here when the streaming is completed, and finally the streaming is triggered again. In fact, it should not be triggered here

58a294639a2a40886bb0fe04caf733f09280ab0d

shanmaocc <47207787+shanmaocc@users.noreply.github.com>

Signed
1 files changed, +6 -6Showing whitespace changes
public/script.js+6 -6
@@ -5719,9 +5719,9 @@ export async function saveReply({ type, getMessage, fromStreaming = false, title
57195719 chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0);
57205720 }
57215721 const chat_id = (chat.length - 1);
57225722 !fromStreaming && await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id, type);
57235723 addOneMessage(chat[chat_id], { type: 'swipe' });
57245724 !fromStreaming && await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id, type);
57255725 } else {
57265726 chat[chat.length - 1]['mes'] = getMessage;
57275727 }
@@ -5743,9 +5743,9 @@ export async function saveReply({ type, getMessage, fromStreaming = false, title
57435743 chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0);
57445744 }
57455745 const chat_id = (chat.length - 1);
57465746 !fromStreaming && await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id, type);
57475747 addOneMessage(chat[chat_id], { type: 'swipe' });
57485748 !fromStreaming && await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id, type);
57495749 } else if (type === 'appendFinal') {
57505750 oldMessage = chat[chat.length - 1]['mes'];
57515751 console.debug('Trying to appendFinal.');
@@ -5764,9 +5764,9 @@ export async function saveReply({ type, getMessage, fromStreaming = false, title
57645764 chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0);
57655765 }
57665766 const chat_id = (chat.length - 1);
57675767 !fromStreaming && await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id, type);
57685768 addOneMessage(chat[chat_id], { type: 'swipe' });
57695769 !fromStreaming && await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id, type);
57705770
57715771 } else {
57725772 console.debug('entering chat update routine for non-swipe post');