From 247038b7ee75997c1a9ae1a7472e5eb5023bc9e8 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期三, 19 二月 2025 14:37:09 +0800
Subject: [PATCH] commit
---
app/api/chat.py | 15 +++++++++++++++
app/api/user.py | 2 +-
app/config/env_conf/menu_conf.json | 8 ++++----
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/app/api/chat.py b/app/api/chat.py
index 6be16e5..5ca3277 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -815,6 +815,7 @@
}
token = DfTokenDao(db).get_token_by_id(token_dict[chat_type])
# print(token)
+ node_list = []
if not token:
await websocket.send_json({"message": "Invalid token", "type": "error"})
@@ -867,6 +868,14 @@
complete_response += rag_response
try:
data = json.loads(complete_response)
+ node_data = deepcopy(data)
+ if "data" in node_data:
+ if "outputs" in node_data["data"]:
+ node_data["data"]["outputs"] = {}
+ if "inputs" in node_data["data"]:
+ node_data["data"]["inputs"] = {}
+ # print(node_data)
+ node_list.append(node_data)
if data.get("event") == "node_started" or data.get(
"event") == "node_finished": # "event": "message_end"
if "data" not in data or not data["data"]: # 淇℃伅杩囨护
@@ -891,6 +900,10 @@
# 姝e父杈撳嚭
answer = data.get("answer", "")
result = {"message": answer, "type": "stream"}
+ elif data.get("event") == "error": # "event": "message_end"
+ # 姝e父杈撳嚭
+ answer = data.get("message", "")
+ result = {"message": answer, "type": "system"}
elif data.get("event") == "workflow_finished":
answer = data.get("data", "")
if isinstance(answer, str):
@@ -913,9 +926,11 @@
message={"role": "assistant",
"content": {
"answer": message,
+ "node_list": node_list,
"download_url": download_url}},
conversation_id=data.get(
"conversation_id"))
+ node_list = []
except Exception as e:
logger.error("淇濆瓨dify鐨勪細璇濆紓甯革紒")
logger.error(e)
diff --git a/app/api/user.py b/app/api/user.py
index c66869e..3dca8be 100644
--- a/app/api/user.py
+++ b/app/api/user.py
@@ -30,7 +30,7 @@
return Response(code=400, msg="The password must be at least 8 and contain both numbers and letters")
db_user = db.query(UserModel).filter(UserModel.username == user.userName, UserModel.status != USER_STATSU_DELETE).first()
if db_user:
- return Response(code=200, msg="user already created")
+ return Response(code=400, msg="user already created")
pwd = user.pwd
if not pwd:
pwd = "basic123456"
diff --git a/app/config/env_conf/menu_conf.json b/app/config/env_conf/menu_conf.json
index 1e52f8b..9fecd0f 100644
--- a/app/config/env_conf/menu_conf.json
+++ b/app/config/env_conf/menu_conf.json
@@ -44,8 +44,8 @@
"rank": 97,
"dialog": [
{
- "id": "7638f006-38a2-4c21-a68e-c6c49b304a35",
- "chat_id": "7638f006-38a2-4c21-a68e-c6c49b304a35",
+ "id": "e138dd77-34d9-40f8-88f8-4d0ba7842b0b",
+ "chat_id": "e138dd77-34d9-40f8-88f8-4d0ba7842b0b",
"chat_type": "documentIa",
"agentType": 4
}
@@ -175,8 +175,8 @@
"rank": 90,
"dialog": [
{
- "id": "e138dd77-34d9-40f8-88f8-4d0ba7842b0b",
- "chat_id": "e138dd77-34d9-40f8-88f8-4d0ba7842b0b",
+ "id": "7638f006-38a2-4c21-a68e-c6c49b304a35",
+ "chat_id": "7638f006-38a2-4c21-a68e-c6c49b304a35",
"chat_type": "documentIaDs",
"agentType": 4
}
--
Gitblit v1.8.0