From c4338024c90cd36a330d42194bb553525828fa3b Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期五, 14 二月 2025 16:28:10 +0800
Subject: [PATCH] 问题优化

---
 app/api/chat.py  |    6 ++++--
 app/api/agent.py |    2 ++
 app/api/user.py  |    2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/api/agent.py b/app/api/agent.py
index fd31c96..0a6429e 100644
--- a/app/api/agent.py
+++ b/app/api/agent.py
@@ -231,6 +231,8 @@
             for i in session.log_to_json().get("message", []):
                 if i.get("role") == "user":
                     tmp_data["question"] = i.get("content")
+                    if "upload_filenames" in i:
+                        tmp_data["upload_filenames"] = i.get("upload_filenames")
                 elif i.get("role") == "assistant":
                     if isinstance(i.get("content"), dict):
                         content = i.get("content", {})
diff --git a/app/api/chat.py b/app/api/chat.py
index 2d2845d..6be16e5 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -435,6 +435,7 @@
                         receive_message = await websocket.receive_json()
                         print(f"Received from client {chat_id}: {receive_message}")
                         upload_files = receive_message.get('upload_files', [])
+                        upload_filenames = receive_message.get('upload_filenames', [])
                         title = receive_message.get('title', "")
                         sub_titles = receive_message.get('sub_titles', "")
                         workflow_type = receive_message.get('workflow', 1)
@@ -458,7 +459,7 @@
                                 AgentType.DIFY,
                                 current_user.id,
                                 {"role": "user", "content": title if title else title_query, "type": workflow_type,
-                                 "is_clean": is_clean},
+                                 "is_clean": is_clean, "upload_filenames":upload_filenames},
                                 workflow_type
                             )
                             conversation_id = session.conversation_id
@@ -823,6 +824,7 @@
                         receive_message = await websocket.receive_json()
                         print(f"Received from client {chat_id}: {receive_message}")
                         upload_file_id = receive_message.get('upload_file_id', [])
+                        upload_filenames = receive_message.get('upload_filenames', [])
                         question = receive_message.get('message', "")
                         if not question and not image_url:
                             await websocket.send_json({"message": "Invalid request", "type": "error"})
@@ -834,7 +836,7 @@
                                 agent_id,
                                 AgentType.DIFY,
                                 current_user.id,
-                                {"role": "user", "content": question}
+                                {"role": "user", "content": question, "upload_filenames": upload_filenames}
                             )
                             conversation_id = session.conversation_id
                         except Exception as e:
diff --git a/app/api/user.py b/app/api/user.py
index 52d1e0f..c66869e 100644
--- a/app/api/user.py
+++ b/app/api/user.py
@@ -23,7 +23,7 @@
 async def add_user(user: UserInfo, current_user: UserModel = Depends(get_current_user), db=Depends(get_db)):
     if not user.userName:
         return Response(code=400, msg="The userName cannot be empty!")
-    if "@" in user.username:
+    if "@" in user.userName:
         return Response(code=400, msg="Username cannot contain @")
     if user.pwd:
         if not is_valid_password(user.pwd):

--
Gitblit v1.8.0