Timothy Jaeryang Baek 2 months ago
parent
commit
df07d671ce
1 changed files with 9 additions and 6 deletions
  1. 9 6
      backend/open_webui/utils/middleware.py

+ 9 - 6
backend/open_webui/utils/middleware.py

@@ -1321,12 +1321,6 @@ async def process_chat_response(
                                         )
 
                                         if end:
-                                            data = {
-                                                "content": serialize_content_blocks(
-                                                    content_blocks
-                                                ),
-                                            }
-
                                             break
 
                                     if ENABLE_REALTIME_CHAT_SAVE:
@@ -1370,6 +1364,15 @@ async def process_chat_response(
                         if not content_blocks[-1]["content"]:
                             content_blocks.pop()
 
+                    await event_emitter(
+                        {
+                            "type": "chat:completion",
+                            "data": {
+                                "content": serialize_content_blocks(content_blocks),
+                            },
+                        }
+                    )
+
                     if response.background:
                         await response.background()