当前位置: 首页 > news >正文

DataEase+MaxKB:让BI再多个“A”

一、前言

当前DataEase BI更多聚焦于BI展示层,然而,在与组件Copilot 以及后续计划替换的 Sqlbot的融合方面,目前仍存在一些亟待解决的问题,当它们尝试与 DataEase 进行结合应用时,出现了两种较为突出的状况。

一方面,Copilot与 DataEase 的集成割裂感过于强烈。这种割裂不仅体现在操作流程上,用户需要在不同组件之间频繁切换,增加了操作的复杂性和繁琐程度;还表现在数据交互层面,组件之间无法实现无缝的数据传递与共享,导致数据的一致性和连贯性受到影响,极大地降低了用户的使用体验。

另一方面,Sqlbot组件在进行数据查询时,往往针对的是全局数据集。这意味着无论用户当前正在关注哪个具体的大屏展示内容,组件所返回的查询结果都是基于整个数据集的宏观信息。但用户在实际使用过程中,通常更希望针对当前所展示大屏中的特定数据进行问答交互和深入解析,以获取与当前展示内容紧密相关的详细信息和分析结果。现有的这种查询方式与用户实际需求之间存在明显偏差,无法精准满足用户对于当前展示大屏数据问答和解析的期望。

基于上述痛点,我们将MaxKB对应应用嵌入DataEase公共链接大屏,可以实现针对当前大屏的智能问答。

二、实现

1、环境准备

·部署DataEase:详见 https://dataease.io/docs/v2/installation/online_installation/

·部署Maxkb:详见 https://maxkb.cn/docs/v2/installation/online_installtion/

2、MaxKB应用制作

2.1 函数库编写

·生成DataEase token

import jwt
import requestsfrom Crypto.Cipher import AES from Crypto.Util.Padding import pad from base64 import b64encode from uuid import uuid4 import time   def generate_token(accessKey,secretKey):     """生成包含AES加密签名的JWT令牌"""     # 生成唯一ID和时间戳     unique_id = str(uuid4())     timestamp = str(time.time_ns() // 1000000)           # AES加密逻辑(原aes_encrypt方法的功能)     src = accessKey + "|" + unique_id + "|" + timestamp     secret_key = secretKey.encode('utf-8')     iv = accessKey.encode('utf-8')     cipher = AES.new(secret_key, AES.MODE_CBC, iv)     encrypted = cipher.encrypt(pad(src.encode('utf-8'), AES.block_size))     signature = b64encode(encrypted).decode('utf-8')           # 生成并返回JWT令牌     token = jwt.encode(         {'accessKey': accessKey, 'signature': signature},         secretKey,         algorithm='HS256'     )     return token

·调用DataEase查询看板详情接口

import requests
import json  def findById(token,id,busiFlag,domain):       # 生成签名和令牌     # 设置请求头     headers = {         'Accept': '*/*',         'Content-Type': 'application/json',         'x-de-ask-token': token     }           requestData = {         'id': id,         'busiFlag': busiFlag,         'source':'main',         'resourceTable':'core'     }       # 发送请求     response = requests.post(domain+'/de2api/dataVisualization/findById', headers=headers, json=requestData)     responseJson = json.loads(response.text)     title_map = {}     for key, value in responseJson['data']['canvasViewInfo'].items():         # 获取每个对象的title作为新的键         title = value.get('title')         if title: # 确保title存在(避免空值)             title_map[title] = value                   return title_map

·获取图表数据

import requests
import json  def getData(token,key,canvasViewMap,domain):       # 生成签名和令牌     # 设置请求头     headers = {         'Accept': '*/*',         'Content-Type': 'application/json',         'x-de-ask-token': token     }           # 发送请求     response = requests.post(domain+'/de2api/chartData/getData', headers=headers, json=canvasViewMap[key])     responseJson = json.loads(response.text)         data = responseJson['data']['data']           shortname_to_name = {         field["fieldShortName"]: field["name"]         for field in data["fields"]     }       mapped_table_rows = []     for row in data["tableRow"]:         mapped_row = {             shortname_to_name[shortname]: value             for shortname, value in row.items()         }         mapped_table_rows.append(mapped_row)               return mapped_table_rows

2.2高级编排

注:

1、其中涉及的id等信息与de嵌入式那里获取类似,应用见附件

2、原理是通过接口查询视图标题(所以视图必须得有标题且不一样,故富文本不支持)

3、中间会用到大模型提取视图标题,目前有些客户本地部署的大模型不能正确提取标题

3、部署Nginx

yum install gcc pcre-devel openssl-devel -y
wget http://nginx.org/download/nginx-1.20.2.tar.gz && tar -zxvf nginx-1.20.2.tar.gz && cd nginx-1.20.2 && ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_v2_module --with-http_sub_module && make && make install

cat /usr/local/nginx/conf/nginx.conf

#user nobody;
worker_processes  1;   #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;   #pid       logs/nginx.pid;     events {     worker_connections  1024; }     http {     include      mime.types;     default_type application/octet-stream;       #log_format main  '$remote_addr - $remote_user [$time_local] "$request" '     #                  '$status $body_bytes_sent "$http_referer" '     #                  '"$http_user_agent" "$http_x_forwarded_for"';       #access_log logs/access.log main;       sendfile       on;     #tcp_nopush    on;       #keepalive_timeout  0;     keepalive_timeout  65;       #gzip on;       server_tokens off;          server {                 listen 8088 ;                            location / {                         proxy_pass  http://localhost:9080/;#DataEase                         server_name_in_redirect off;                         proxy_http_version      1.1;                         proxy_set_header       Upgrade        $http_upgrade;                         proxy_set_header       Connection "upgrade";                           proxy_set_header          Host $host:$server_port;                         proxy_set_header          X-Real-IP $remote_addr;                         proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;                         proxy_set_header          X-Forwarded-Proto $scheme;                           sub_filter '</head>' '<script async defer src="http://XXX:8080/chat/api/embed?protocol=http&host=XXX:8080&token=XXXX"></script>'; #MaxKB应用嵌入                         sub_filter_once on;                 }         }       server {         listen       80;         server_name localhost;           #charset koi8-r;           #access_log logs/host.access.log main;           location / {             root  html;             index index.html index.htm;         }     } }

4、效果展示

三、优化点

  1. 应用中的提示词可以根据实际需求优化,也可以与智能问数场景结合;
  2. 当前nginx那边多个大屏+对应mk应用需要多个url代理
通过网盘分享的文件:DataEase.mk
链接: https://pan.baidu.com/s/1bRJLBHasveXR4l4wPPaE8g?pwd=7htt 提取码: 7htt
http://www.dtcms.com/a/349744.html

相关文章:

  • 从零开始学习单片机15
  • 【OLAP】trino客户端访问Trino CLI和JDBC
  • 如何恢复删除的照片和视频?视频照片恢复的专业指南
  • zookeeper基础概念及部署
  • 蛋白质结构信息学大纲
  • Linux(四):进程状态
  • 计算机毕业设计 java 血液中心服务系统 基于 Java 的血液管理平台Java 开发的血液服务系统
  • 如何清除 Docker 容器的日志 ?
  • LevelDB SSTable模块
  • mac设置鼠标滚轮方向
  • Elasticsearch脑裂紧急处理与预防
  • 数据挖掘5.3 PCA主成分分析降维
  • AI模型接入Web搜索功能实践与最佳API服务选型
  • 扭蛋机小程序系统开发:连接线上线下娱乐的新桥梁
  • 习题库小程序的设计与实现 计算机毕业设计源码27057
  • RAG检索增强生成
  • SuiHub 台北站正式发布,助力亚洲科技生态创新
  • [读论文]Hunyuan 3D 系列
  • 【Linux系统】1.Linux基础指令与权限
  • 8月25号打卡
  • 数据采集怎么做?质量、效率与合规该怎么平衡?
  • LLM学习:langchain架构——chain
  • 2025年03月 Python(二级)真题解析#中国电子学会#全国青少年软件编程等级考试
  • 【AGI使用教程】GPT-OSS 本地部署(2)
  • 【广告系列】流量优选
  • 第二章 设计模式故事会之策略模式:魔王城里的勇者传说
  • AcrelEMS-EDU在实践中的应用系列—“综合能源管理”
  • 2025年8月25日-8月31日(qtopengl+ue独立游戏)
  • 23种设计模式:模板方法模式与策略模式
  • vue 一键打包上传