Timothy Jaeryang Baek 4 months ago
parent
commit
271acb2e67
1 changed files with 9 additions and 0 deletions
  1. 9 0
      backend/open_webui/utils/middleware.py

+ 9 - 0
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