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
Signed| @@ -5719,9 +5719,9 @@ export async function saveReply({ type, getMessage, fromStreaming = false, title | ||
| 5719 | 5719 | chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0); |
| 5720 | 5720 | } |
| 5721 | 5721 | const chat_id = (chat.length - 1); |
| 5722 | 5722 | !fromStreaming && await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id, type); |
| 5723 | 5723 | addOneMessage(chat[chat_id], { type: 'swipe' }); |
| 5724 | 5724 | !fromStreaming && await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id, type); |
| 5725 | 5725 | } else { |
| 5726 | 5726 | chat[chat.length - 1]['mes'] = getMessage; |
| 5727 | 5727 | } |
| @@ -5743,9 +5743,9 @@ export async function saveReply({ type, getMessage, fromStreaming = false, title | ||
| 5743 | 5743 | chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0); |
| 5744 | 5744 | } |
| 5745 | 5745 | const chat_id = (chat.length - 1); |
| 5746 | 5746 | !fromStreaming && await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id, type); |
| 5747 | 5747 | addOneMessage(chat[chat_id], { type: 'swipe' }); |
| 5748 | 5748 | !fromStreaming && await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id, type); |
| 5749 | 5749 | } else if (type === 'appendFinal') { |
| 5750 | 5750 | oldMessage = chat[chat.length - 1]['mes']; |
| 5751 | 5751 | console.debug('Trying to appendFinal.'); |
| @@ -5764,9 +5764,9 @@ export async function saveReply({ type, getMessage, fromStreaming = false, title | ||
| 5764 | 5764 | chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0); |
| 5765 | 5765 | } |
| 5766 | 5766 | const chat_id = (chat.length - 1); |
| 5767 | 5767 | !fromStreaming && await eventSource.emit(event_types.MESSAGE_RECEIVED, chat_id, type); |
| 5768 | 5768 | addOneMessage(chat[chat_id], { type: 'swipe' }); |
| 5769 | 5769 | !fromStreaming && await eventSource.emit(event_types.CHARACTER_MESSAGE_RENDERED, chat_id, type); |
| 5770 | 5770 | |
| 5771 | 5771 | } else { |
| 5772 | 5772 | console.debug('entering chat update routine for non-swipe post'); |