소스 검색

报告生成增加

zhaoqingang 1 년 전
부모
커밋
0078ac6ffa
6개의 변경된 파일245개의 추가작업 그리고 11개의 파일을 삭제
  1. 1 1
      app/api/files.py
  2. 12 0
      app/config/env_conf/admin.yaml
  3. 9 3
      app/config/env_conf/menu_conf.json
  4. 12 6
      app/init_config/init_run_data.py
  5. 42 1
      app/service/v2/initialize_data.py
  6. 169 0
      menu_conf.json

+ 1 - 1
app/api/files.py

@@ -118,7 +118,7 @@ async def upload_files(
                 raise HTTPException(status_code=500, detail=str(e))
         elif agent.chat_type == "reportWorkflow" or agent.chat_type == "documentIa" or agent.chat_type == "paperTalk":
             token_dict = {
-                "reportWorkflow": DOCUMENT_TO_REPORT,
+                "reportWorkflow": DOCUMENT_TO_REPORT_TITLE,
                 "documentIa": DOCUMENT_IA_QUESTIONS,
                 "paperTalk": DOCUMENT_TO_PAPER,
             }

+ 12 - 0
app/config/env_conf/admin.yaml

@@ -0,0 +1,12 @@
+smart_server:
+  account: administer
+  password: basic@2025
+
+ragflow_app:
+  id: 2c039666c29d11efa4670242ac1b0006
+  account: admin@example.com
+  password: basic@2025
+
+dify_app:
+  account: admin@mail.com
+  password: basic@2025

+ 9 - 3
app/config/env_conf/menu_conf.json

@@ -138,7 +138,7 @@
     },
     {
       "id": 9,
-      "title": "",
+      "title": "报告生成",
       "icon": "2",
       "img": "/src/assets/index/2.png",
       "desc": "基于您创建的报告格式和上传的文档内容,快速生成定制报告,并支持一键下载。",
@@ -146,13 +146,19 @@
       "rank": 91,
       "dialog": [
         {
-          "id": "72a69e47-458d-47f9-b534-1859e5da244f",
+          "id": "87b8e17c-594d-424f-b9f8-0b56036904c9",
           "chat_id": "basic_report_clean",
           "chat_type": "reportWorkflow",
           "agentType": 4
         },
         {
-          "id": "6eda0700-6273-488d-a97c-88d315bd9d8f",
+          "id": "61d26deb-9371-4f9c-b61b-b9f9a24a9188",
+          "chat_id": "basic_report_clean",
+          "chat_type": "reportWorkflow",
+          "agentType": 4
+        },
+        {
+          "id": "d6eea92d-444a-4658-b9e7-9ab7bd5cb19d",
           "chat_id": "basic_report_clean",
           "chat_type": "reportWorkflow",
           "agentType": 4

+ 12 - 6
app/init_config/init_run_data.py

@@ -1,15 +1,21 @@
 from app.models.base_model import SessionLocal
 from app.service.v2.initialize_data import dialog_menu_sync, default_group_sync, default_role_sync, app_register_sync, \
-    basic_agent_sync
+    basic_agent_sync, admin_user_sync
 
 
 async def sync_default_data():
     db = SessionLocal()
-    await dialog_menu_sync(db)  # 小数
-    await default_group_sync(db) # 默认组
-    await default_role_sync(db) # 默认角色
-    await app_register_sync(db) # 注册的应用
-    await basic_agent_sync(db) # 开发的agent
+    try:
+        await dialog_menu_sync(db)  # 小数
+        await default_group_sync(db)  # 默认组
+        await default_role_sync(db)  # 默认角色
+        await app_register_sync(db)  # 注册的应用
+        await basic_agent_sync(db)  # 开发的agent
+        await admin_user_sync(db)  # 开发的agent
+    except Exception as e:
+        print(e)
+    finally:
+        db.close()
     # await default_role_sync(db)  # 页面资源配置信息
     # await default_role_sync(db)  # 默认的角色资源
 

+ 42 - 1
app/service/v2/initialize_data.py

@@ -1,8 +1,13 @@
 import json
 import time
 import os
+
+import yaml
+from passlib.context import CryptContext
+
 from Log import logger
-from app.config.const import DIFY, ENV_CONF_PATH
+# from app.api import pwd_context
+from app.config.const import DIFY, ENV_CONF_PATH, RAGFLOW
 from app.models import MenuCapacityModel, WebMenuModel, GroupModel, RoleModel, DialogModel, UserModel, UserAppModel, \
     cipher_suite
 from app.service.auth import UserAppDao
@@ -14,6 +19,8 @@ from app.service.v2.app_register import AppRegisterDao
 from app.config.config import settings
 from app.utils.password_handle import generate_password
 
+pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
+
 
 async def dialog_menu_sync(db):
     menu_list = []
@@ -219,3 +226,37 @@ async def save_db(db, username, password, email, user_id, app_id, app_type):
     if not user_id:
         raise Exception("Failed to register with app")
     print({"msg": "User registered successfully", "userFlag": user_id})
+
+
+async def admin_user_sync(db):
+    try:
+        config = {}
+        with open(os.path.join(ENV_CONF_PATH, "admin.yaml"), 'r', encoding='utf-8') as file:
+            # 加载JSON数据
+            config = yaml.safe_load(file)
+        # print(config)
+        db_user = db.query(UserModel).filter(UserModel.username == config["smart_server"]["account"]).first()
+        if db_user:
+            print("admin_user_sync: 用户已经存在!")
+            return
+        register_dict = {}
+
+        for app in [RAGFLOW, DIFY]:
+            register_dict[app] = {"id": config[app].get("id", "123"), "name": config[app]["account"],
+                                        "pwd":config[app]["password"],
+                                        "email": config[app]["account"]}
+
+        # 存储用户信息
+        hashed_password = pwd_context.hash(config["smart_server"]["password"])
+        user_model = UserModel(username=config["smart_server"]["account"], hashed_password=hashed_password, email="",
+                               phone="", login_name="", sync_flag="", creator=0, permission="admin")
+        db.add(user_model)
+        db.commit()
+        db.refresh(user_model)
+        u_id = user_model.id
+        user_app_dao = UserAppDao(db)
+        for k, v in register_dict.items():
+            await user_app_dao.update_and_insert_data(v.get("name"), user_model.encrypted_password(v.get("pwd")), v.get("email"), u_id, str(v.get("id")), k)
+    except Exception as e:
+        print(e)
+        db.rollback()

+ 169 - 0
menu_conf.json

@@ -0,0 +1,169 @@
+{
+  "data": [
+    {
+      "id": 1,
+      "title": "报表合并",
+      "icon": "6",
+      "img": "/src/assets/index/6.png",
+      "desc": "基于您上传的报表进行合并,助您快速完成报表整合与分析",
+      "describe": "基于您上传的报表进行合并,助您快速完成报表整合与分析",
+      "dialog": [
+        {
+          "id": "basic_excel_merge",
+          "chat_id": "basic_excel_merge",
+          "chat_type": "excelMerge",
+          "agentType": 3
+        }
+      ],
+      "rank": 99
+    },
+    {
+      "id": 2,
+      "title": "知识问答",
+      "icon": "5",
+      "img": "/src/assets/index/5.png",
+      "desc": "遍历已创建的文档知识库,生成完整和准确的答案,同时显示来源文档供您参考",
+      "describe": "垂域知识的问答助手,针对你的提问,我们将遍历已创建的文档知识库,生成完整和准确的答案,同时显示来源文档供您参考。",
+      "rank": 105,
+      "dialog": [
+        {
+          "id": "e476db7cbdbb11ef82b50242ac130006",
+          "chat_id": "e476db7cbdbb11ef82b50242ac130006",
+          "chat_type": "knowledgeQA",
+          "agentType": 1
+        }
+      ]
+    },
+    {
+      "id": 3,
+      "title": "文档智能",
+      "icon": "7",
+      "img": "/src/assets/index/7.png",
+      "desc": "个人知识库的问答助手,基于您上传的文档进行问答,支持多文档",
+      "describe": "个人知识库的问答助手,基于您上传的文档进行问答,支持多文档,大小在30M以内。",
+      "rank": 97,
+      "dialog": [
+        {
+          "id": "7638f006-38a2-4c21-a68e-c6c49b304a35",
+          "chat_id": "7638f006-38a2-4c21-a68e-c6c49b304a35",
+          "chat_type": "documentIa",
+          "agentType": 4
+        }
+      ]
+    },
+    {
+      "id": 4,
+      "title": "智能问答",
+      "icon": "1",
+      "img": "/src/assets/index/1.png",
+      "desc": "能够理解和学习人类的语言,具备多轮对话的能力",
+      "describe": "我可以理解和学习人类的语言,具备多轮对话的能力,现在和我开始交流吧~",
+      "rank": 104,
+      "dialog": [
+        {
+          "id": "90d533729c0211efbf6b0242ac160006",
+          "chat_id": "90d533729c0211efbf6b0242ac160006",
+          "chat_type": "chat",
+          "agentType": 1
+        }
+      ]
+    },
+    {
+      "id": 5,
+      "title": "智能数据",
+      "icon": "8",
+      "img": "/src/assets/index/8.png",
+      "desc": "您可以上传文档或添加数据库地址,小数可针对你文档的数据进行分析,并生成指定的图表",
+      "describe": "您可以上传文档或添加数据库地址,小数可针对你文档的数据进行分析,并生成指定的图表",
+      "rank": 95,
+      "dialog": [
+        {
+          "id": "basic_excel_talk",
+          "chat_id": "basic_excel_talk",
+          "chat_type": "excelTalk",
+          "agentType": 3
+        }
+      ]
+    },
+    {
+      "id": 6,
+      "title": "小数绘图",
+      "icon": "7",
+      "img": "/src/assets/index/7.png",
+      "desc": "基于您上传的图片,生成对应的文字描述并基于图片内容实现问答。",
+      "describe": "基于您上传的图片,生成对应的文字描述并基于图片内容实现问答。",
+      "rank": 94,
+      "dialog": [
+        {
+          "id": "9d75142a-66eb-4e23-b7d4-03efe4584915",
+          "chat_id": "9d75142a-66eb-4e23-b7d4-03efe4584915",
+          "chat_type": "imageTalk",
+          "agentType": 4
+        }
+      ]
+    },
+    {
+      "id": 7,
+      "title": "文档出卷",
+      "icon": "6",
+      "img": "/src/assets/index/6.png",
+      "desc": "您可以上传文档,小数能针对单文档或多个文档内容自动出题,高效便捷的帮助你建立私人题库。",
+      "describe": "您可以上传文档,小数能针对单文档或多个文档内容自动出题,高效便捷的帮助你建立私人题库。",
+      "rank": 93,
+      "dialog": [
+        {
+          "id": "2f6ddf93-7ba6-4b2d-b991-d96421404600",
+          "chat_id": "2f6ddf93-7ba6-4b2d-b991-d96421404600",
+          "chat_type": "paperTalk",
+          "agentType": 4
+        }
+      ]
+    },
+    {
+      "id": 8,
+      "title": "出题组卷",
+      "icon": "6",
+      "img": "/src/assets/index/6.png",
+      "desc": "您可以上传文档,小数能针对单文档或多个文档内容自动出题,高效便捷的帮助你建立私人题库。",
+      "describe": "您可以上传文档,小数能针对单文档或多个文档内容自动出题,高效便捷的帮助你建立私人题库。",
+      "rank": 92,
+      "dialog": [
+         {
+          "id": "basic_question_talk",
+          "chat_id": "basic_question_talk",
+          "chat_type": "questionTalk",
+          "agentType": 3
+        }
+      ]
+    },
+    {
+      "id": 9,
+      "title": "报告生成",
+      "icon": "2",
+      "img": "/src/assets/index/2.png",
+      "desc": "基于您创建的报告格式和上传的文档内容,快速生成定制报告,并支持一键下载。",
+      "describe": "基于您创建的报告格式和上传的文档内容,快速生成定制报告,并支持一键下载。",
+      "rank": 91,
+      "dialog": [
+        {
+          "id": "87b8e17c-594d-424f-b9f8-0b56036904c9",
+          "chat_id": "basic_report_clean",
+          "chat_type": "reportWorkflow",
+          "agentType": 4
+        },
+        {
+          "id": "61d26deb-9371-4f9c-b61b-b9f9a24a9188",
+          "chat_id": "basic_report_clean",
+          "chat_type": "reportWorkflow",
+          "agentType": 4
+        },
+        {
+          "id": "d6eea92d-444a-4658-b9e7-9ab7bd5cb19d",
+          "chat_id": "basic_report_clean",
+          "chat_type": "reportWorkflow",
+          "agentType": 4
+        }
+      ]
+    }
+  ]
+}