From 271acb2e67baec77645197c2c8bbe248724a0c92 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 21 Dec 2024 09:45:52 -0700 Subject: [PATCH] refac --- backend/open_webui/utils/middleware.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 9261c26b3..a33b34814 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -561,6 +561,15 @@ async def process_chat_response(request, response, user, events, metadata, tasks } ) + # Save message in the database + Chats.upsert_message_to_chat_by_id_and_message_id( + metadata["chat_id"], + metadata["message_id"], + { + **event, + }, + ) + content = "" async for line in response.body_iterator: line = line.decode("utf-8") if isinstance(line, bytes) else line