From a9caccfe34e6126270f41533c4b6dc7c79c66273 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 17 十月 2024 13:58:35 +0800
Subject: [PATCH] 上传文件时传入文件名

---
 app/api/chat.py |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/app/api/chat.py b/app/api/chat.py
index 458581a..fa53467 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -47,11 +47,14 @@
                     print(f"Received from client {chat_id}: {message}")
                     chat_history = message.get('chatHistory', [])
                     if len(chat_history) == 0:
-
-                        chat_history = await ragflow_service.set_session(token, agent_id, message["message"], chat_id, True)
+                        chat_history = await ragflow_service.get_session_history(token, agent_id)
                         if len(chat_history) == 0:
-                            result = {"message": "鍐呴儴閿欒锛氬垱寤轰細璇濆け璐�", "type": "close"}
-                            await websocket.send_json(result)
+                            chat_history = await ragflow_service.set_session(token, agent_id,
+                                                                             message["message"], chat_id, True)
+                            if len(chat_history) == 0:
+                                result = {"message": "鍐呴儴閿欒锛氬垱寤轰細璇濆け璐�", "type": "close"}
+                                await websocket.send_json(result)
+                                return
                     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