From c570e362ed163412658d1c1648e938a027529fed Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 17 十月 2024 21:38:19 +0800
Subject: [PATCH] 文档上传接口支持ragflow上传并解析

---
 app/api/chat.py |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/app/api/chat.py b/app/api/chat.py
index 97babf6..a847431 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -46,21 +46,19 @@
                     message = await websocket.receive_json()
                     print(f"Received from client {chat_id}: {message}")
                     chat_history = message.get('chatHistory', [])
+                    message["role"] = "user"
                     if len(chat_history) == 0:
                         chat_history = await ragflow_service.get_session_history(token, chat_id)
                         if len(chat_history) == 0:
                             chat_history = await ragflow_service.set_session(token, agent_id,
-                                                                             message["message"], chat_id, True)
+                                                                             message, chat_id, True)
                             if len(chat_history) == 0:
                                 result = {"message": "鍐呴儴閿欒锛氬垱寤轰細璇濆け璐�", "type": "close"}
                                 await websocket.send_json(result)
                                 await websocket.close()
                                 return
                         else:
-                            chat_history.append({
-                                "content": message["message"],
-                                "role": "user"
-                            })
+                            chat_history.append(message)
                     async for rag_response in ragflow_service.chat(token, chat_id, chat_history):
                         try:
                             print(f"Received from ragflow: {rag_response}")

--
Gitblit v1.8.0