fix sse js event
This commit is contained in:
@@ -232,11 +232,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
return false;
|
||||
}
|
||||
|
||||
function cleanupThinkSpans(container) {
|
||||
function cleanupThinkSpans(container, final = false) {
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (final) {
|
||||
removeThinkSpansOnly(container);
|
||||
return;
|
||||
}
|
||||
|
||||
const thinkSpans = Array.from(container.querySelectorAll('.think'));
|
||||
|
||||
if (thinkSpans.length === 0) {
|
||||
@@ -254,9 +259,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
removeThinkSpansOnly(container);
|
||||
}
|
||||
|
||||
function renderBubbleContent(bubble, raw) {
|
||||
function renderBubbleContent(bubble, raw, final = false) {
|
||||
bubble.innerHTML = renderMarkdown(raw);
|
||||
cleanupThinkSpans(bubble);
|
||||
cleanupThinkSpans(bubble, final);
|
||||
enhanceChatLinks(bubble);
|
||||
scrollChatToBottom();
|
||||
}
|
||||
@@ -333,7 +338,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
function finalizeStream(bubble, raw) {
|
||||
clearScheduledRender();
|
||||
renderBubbleContent(bubble, raw);
|
||||
bubble.classList.remove('loader');
|
||||
renderBubbleContent(bubble, raw, true);
|
||||
}
|
||||
|
||||
async function releaseStreamResources() {
|
||||
@@ -567,7 +573,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (raw.trim() !== '') {
|
||||
const formattedMessage = `<em>${userMessage}</em>`;
|
||||
raw += raw.trim() === '' ? formattedMessage : `\n\n${formattedMessage}`;
|
||||
renderBubbleContent(bubble, raw);
|
||||
renderBubbleContent(bubble, raw, true);
|
||||
} else {
|
||||
bubble.innerHTML = `<em>${userMessage}</em>`;
|
||||
enhanceChatLinks(bubble);
|
||||
|
||||
Reference in New Issue
Block a user