From cf0aca1487fd423c6ac17ce586b6caaf178836e1 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 20 Dec 2024 18:37:25 -0800 Subject: [PATCH] fix --- backend/open_webui/utils/middleware.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 6d46b738d..472f4ecf0 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -528,7 +528,14 @@ async def process_chat_response(request, response, user, events, metadata, tasks return response event_emitter = None - if "session_id" in metadata: + if ( + "session_id" in metadata + and metadata["session_id"] + and "chat_id" in metadata + and metadata["chat_id"] + and "message_id" in metadata + and metadata["message_id"] + ): event_emitter = get_event_emitter(metadata) if event_emitter: @@ -701,6 +708,7 @@ async def process_chat_response(request, response, user, events, metadata, tasks return {"status": True, "task_id": task_id} else: + # Fallback to the original response async def stream_wrapper(original_generator, events): def wrap_item(item):