Timothy Jaeryang Baek 1 개월 전
부모
커밋
8cca648efa
1개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. 19 0
      backend/open_webui/socket/main.py

+ 19 - 0
backend/open_webui/socket/main.py

@@ -722,6 +722,25 @@ def get_event_emitter(request_info, update_db=True):
                     },
                 )
 
+            if event_data.get("type") in ["source", "citation"]:
+                data = event_data.get("data", {})
+                if data.get("type") == None:
+                    message = Chats.get_message_by_id_and_message_id(
+                        request_info["chat_id"],
+                        request_info["message_id"],
+                    )
+
+                    sources = message.get("sources", [])
+                    sources.append(data)
+
+                    Chats.upsert_message_to_chat_by_id_and_message_id(
+                        request_info["chat_id"],
+                        request_info["message_id"],
+                        {
+                            "sources": sources,
+                        },
+                    )
+
     return __event_emitter__