From df07d671ce17548bd28f8147e6ca6a0c8e22fe90 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 3 Feb 2025 16:21:44 -0800 Subject: [PATCH] refac --- backend/open_webui/utils/middleware.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 71e32c755..ffccdca87 100644 --- a/backend/open_webui/utils/middleware.py +++ b/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()