zhaoqingang
2025-02-19 247038b7ee75997c1a9ae1a7472e5eb5023bc9e8
commit

tmp
3个文件已修改
25 ■■■■ 已修改文件
app/api/chat.py 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/api/user.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/config/env_conf/menu_conf.json 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 @@
                                        # 正常输出
                                        answer = data.get("answer", "")
                                        result = {"message": answer, "type": "stream"}
                                    elif data.get("event") == "error":  # "event": "message_end"
                                        # 正常输出
                                        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)
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"
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
        }