
DIFY chatBI demo实现
开局一张图,余下全靠编!
app: description: '' icon: icon_background: '#FFEAD5' mode: advanced-chat name: Chatflow use_icon_as_answer_icon: false dependencies: - current_identifier: null type: marketplace value: marketplace_plugin_unique_identifier: hjlarry/database:0.0.6@2f547ea4b80c5bbec2b953843a37de9aff7427d276b763a8e237c6b2188359b3 - current_identifier: null type: marketplace value: marketplace_plugin_unique_identifier: langgenius/echarts:0.0.1@fe95412f101f2735530ea05f479ab5e8fbe1d4f4b2847f09e490e7d1d0125de5 - current_identifier: null type: marketplace value: marketplace_plugin_unique_identifier: langgenius/tongyi:0.0.25@325423749d5e71f8b4681af1b2ed46d7686cb1947e443a86ba5d14ac45ff85a4 kind: app version: 0.3.0 workflow: conversation_variables: [] environment_variables: [] features: file_upload: allowed_file_extensions: - .JPG - .JPEG - .PNG - .GIF - .WEBP - .SVG allowed_file_types: - image allowed_file_upload_methods: - local_file - remote_url enabled: false fileUploadConfig: audio_file_size_limit: 50 batch_count_limit: 5 file_size_limit: 15 image_file_size_limit: 10 video_file_size_limit: 100 workflow_file_upload_limit: 10 image: enabled: false number_limits: 3 transfer_methods: - local_file - remote_url number_limits: 3 opening_statement: 欢迎使用预约智能AI分析工具 retriever_resource: enabled: true sensitive_word_avoidance: enabled: false speech_to_text: enabled: false suggested_questions: - 查询2025年每月的预约总数量 suggested_questions_after_answer: enabled: false text_to_speech: enabled: false language: '' voice: '' graph: edges: - data: sourceType: start targetType: llm id: 1748232717514-llm selected: false source: '1748232717514' sourceHandle: source target: llm targetHandle: target type: custom - data: isInLoop: false sourceType: parameter-extractor targetType: tool id: 1748238509042-source-1748233419496-target source: '1748238509042' sourceHandle: source target: '1748233419496' targetHandle: target type: custom zIndex: 0 - data: isInLoop: false sourceType: llm targetType: answer id: llm-source-1748238559410-target source: llm sourceHandle: source target: '1748238559410' targetHandle: target type: custom zIndex: 0 - data: isInLoop: false sourceType: answer targetType: parameter-extractor id: 1748238559410-source-1748238509042-target source: '1748238559410' sourceHandle: source target: '1748238509042' targetHandle: target type: custom zIndex: 0 - data: isInIteration: false isInLoop: false sourceType: llm targetType: answer id: 1748241163811--1748241283508-target source: '1748241163811' sourceHandle: source target: '1748241283508' targetHandle: target type: custom zIndex: 0 - data: isInLoop: false sourceType: code targetType: answer id: 1748240618227-source-1748240646067-target source: '1748240618227' sourceHandle: source target: '1748240646067' targetHandle: target type: custom zIndex: 0 - data: isInLoop: false sourceType: answer targetType: tool id: 1748241283508-source-1748241638404-target source: '1748241283508' sourceHandle: source target: '1748241638404' targetHandle: target type: custom zIndex: 0 - data: isInLoop: false sourceType: tool targetType: answer id: 1748241638404-source-1748242416972-target source: '1748241638404' sourceHandle: source target: '1748242416972' targetHandle: target type: custom zIndex: 0 - data: isInLoop: false sourceType: tool targetType: code id: 1748233419496-source-1748240618227-target selected: false source: '1748233419496' sourceHandle: source target: '1748240618227' targetHandle: target type: custom zIndex: 0 - data: isInLoop: false sourceType: answer targetType: llm id: 1748240646067-source-1748241163811-target source: '1748240646067' sourceHandle: source target: '1748241163811' targetHandle: target type: custom zIndex: 0 nodes: - data: desc: '' selected: false title: 开始 type: start variables: [] height: 53 id: '1748232717514' position: x: -261.1634114341191 y: 394.57243878970934 positionAbsolute: x: -261.1634114341191 y: 394.57243878970934 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: context: enabled: true variable_selector: - sys - query desc: '' memory: query_prompt_template: '{{#sys.query#}}' role_prefix: assistant: '' user: '' window: enabled: false size: 10 model: completion_params: {} mode: chat name: qwen-turbo provider: langgenius/tongyi/tongyi prompt_template: - id: fd785178-20e4-48e1-bcf4-715086728dd2 role: system text: "# 你是数据分析专家,精通MYSQL,能够根据用户的问题生成高效的SQL查询并执行SQL返回结果, 详细规则如下\n\n## 核心规则\n\ 1. 仅使用提供的数据库表结构和字段,且只能使用SELECT关键字,不允许使用udpate和delete\n2. 确保SQL语句兼容MYSQL语法\n\ 3.输出一个完整的SQL语句字符串,无注释,不用markdown格式,只要纯SQL字符串\n\n \n## 数据库表结构 \n### 1.\ \ user(用户表)\n#### 字段说明\n- id: 用户ID\n- username: 用户姓名\n- phone: 用户电话\n\n\ ### 2. patient(患者表)\n#### 字段说明\n- name: 姓名\n- gender: 性别\n- birthday:患者生日\n\ \n### 3. user_reservation(预约记录表)\n#### 字段说明\n- id: 主键\n- user_id: 用户ID\n\ - patient_id:患者ID\n- reservation_date: 预约日期\n- reservation_time: 预约时段\n\ - status: 预约状态\n- create_time: 创建日期\n\n\n## 查询技巧\n### 聚合函数\n- COUNT():\ \ 计算数量\n- AVG(): 计算平均值\n- SUM(): 计算总和\n- MAX()/MIN(): 获取最大/最小值\n \n##\ \ 注意事项 \n1. 合理使用JOIN条件\n2. 注意日期格式的一致性\n3. 使用适当的sql语句以提高查询效率\n\n## 输出格式\n\ 1. 仅输出SQL字符串,不包含格式\n\n\n" selected: false structured_output_enabled: false title: LLM type: llm variables: [] vision: enabled: false height: 89 id: llm position: x: 162.8960109055606 y: 18.948076705679185 positionAbsolute: x: 162.8960109055606 y: 18.948076705679185 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: desc: 执行SQL is_team_authorization: true output_schema: null paramSchemas: - auto_generate: null default: null form: llm human_description: en_US: The SQL query string. ja_JP: The SQL query string. pt_BR: The SQL query string. zh_Hans: SQL 查询语句。 label: en_US: SQL Query ja_JP: SQL Query pt_BR: SQL Query zh_Hans: SQL 查询语句 llm_description: The SQL query string. max: null min: null name: query options: [] placeholder: null precision: null required: true scope: null template: null type: string - auto_generate: null default: null form: llm human_description: en_US: Optional, Filling in this field will overwrite the database connection entered during authorization. ja_JP: Optional, Filling in this field will overwrite the database connection entered during authorization. pt_BR: Optional, Filling in this field will overwrite the database connection entered during authorization. zh_Hans: 选填,填写后将覆盖授权时填写的数据库连接。 label: en_US: DB URI ja_JP: DB URI pt_BR: DB URI zh_Hans: DB URI llm_description: '' max: null min: null name: db_uri options: [] placeholder: null precision: null required: false scope: null template: null type: string - auto_generate: null default: json form: form human_description: en_US: Choose the output format. ja_JP: Choose the output format. pt_BR: Choose the output format. zh_Hans: 选择输出格式。 label: en_US: Output format ja_JP: Output format pt_BR: Output format zh_Hans: 输出格式 llm_description: '' max: null min: null name: format options: - label: en_US: JSON ja_JP: JSON pt_BR: JSON zh_Hans: JSON value: json - label: en_US: CSV ja_JP: CSV pt_BR: CSV zh_Hans: CSV value: csv - label: en_US: YAML ja_JP: YAML pt_BR: YAML zh_Hans: YAML value: yaml - label: en_US: Markdown ja_JP: Markdown pt_BR: Markdown zh_Hans: Markdown value: md - label: en_US: Excel ja_JP: Excel pt_BR: Excel zh_Hans: Excel value: xlsx - label: en_US: HTML ja_JP: HTML pt_BR: HTML zh_Hans: HTML value: html placeholder: null precision: null required: false scope: null template: null type: select - auto_generate: null default: null form: form human_description: en_US: 'Optional. For example {"connect_args": {"ssl": {"ca": "/path/to/ca.pem"}}} More connection options can be found at https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine ' ja_JP: 'Optional. For example {"connect_args": {"ssl": {"ca": "/path/to/ca.pem"}}} More connection options can be found at https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine ' pt_BR: 'Optional. For example {"connect_args": {"ssl": {"ca": "/path/to/ca.pem"}}} More connection options can be found at https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine ' zh_Hans: '选填项。例如 {"connect_args": {"ssl": {"ca": "/path/to/ca.pem"}}} 更多连接选项可参考 https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine ' label: en_US: DB Config Options ja_JP: DB Config Options pt_BR: DB Config Options zh_Hans: 数据库连接配置选项 llm_description: '' max: null min: null name: config_options options: [] placeholder: null precision: null required: false scope: null template: null type: string params: config_options: '' db_uri: '' format: '' query: '' provider_id: hjlarry/database/database provider_name: hjlarry/database/database provider_type: builtin selected: false title: SQL Execute tool_configurations: config_options: null format: '' tool_description: 此工具用于在已存在的数据库中执行 SQL 查询。 tool_label: SQL Execute tool_name: sql_execute tool_parameters: db_uri: type: mixed value: mysql+pymysql://root:root@localhost:3306/homecare query: type: mixed value: '{{#1748238509042.text#}}' type: tool height: 143 id: '1748233419496' position: x: 185.20036537094296 y: 361.35120425039713 positionAbsolute: x: 185.20036537094296 y: 361.35120425039713 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: desc: 提取SQL字符串 model: completion_params: temperature: 0.7 mode: chat name: qwen-turbo provider: langgenius/tongyi/tongyi parameters: - description: 提取SQL语句 name: text required: false type: string query: - llm - text reasoning_mode: prompt selected: false title: 参数提取器 type: parameter-extractor variables: [] vision: enabled: false height: 117 id: '1748238509042' position: x: 936.6553264450904 y: 18.948076705679185 positionAbsolute: x: 936.6553264450904 y: 18.948076705679185 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: answer: ' ### 生成SQL成功: {{#llm.text#}}' desc: '' selected: false title: 打印SQL type: answer variables: [] height: 120 id: '1748238559410' position: x: 555.9930526737288 y: 18.948076705679185 positionAbsolute: x: 555.9930526737288 y: 18.948076705679185 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: code: "import json\n\ndef main(arg1: str) -> str:\n\n return {\n \ \ \"result\": json.dumps(arg1)\n }\n" code_language: python3 desc: '' outputs: result: children: null type: string selected: false title: 代码执行 type: code variables: - value_selector: - '1748233419496' - json variable: arg1 height: 53 id: '1748240618227' position: x: 535.1723860641345 y: 361.35120425039713 positionAbsolute: x: 535.1723860641345 y: 361.35120425039713 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: answer: ' ### SQL执行结果: {{#1748240618227.result#}}' desc: '' selected: false title: 直接回复 2 type: answer variables: [] height: 120 id: '1748240646067' position: x: 952.4894213743651 y: 361.35120425039713 positionAbsolute: x: 952.4894213743651 y: 361.35120425039713 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: context: enabled: true variable_selector: - '1748240618227' - result desc: '' model: completion_params: {} mode: chat name: qwen-max provider: langgenius/tongyi/tongyi prompt_template: - id: c21f1c09-011f-4b51-a6ec-d5edc4dc0fb8 role: system text: '请根据用户的问题 {{#sys.query#}},并结合执行结果 {{#context#}},如果数据中有缺失的年/月/日,请按照以下规则补全数据: 1. 缺失的日期应按照时间序列及正确的日期格式补全。 2. 缺失的数据点应使用 0 表示,且顺序必须和日期对应。 根据补全后的数据生成开源图表库echarts,生成Echarts所需要的option配置JSON。并提取title, data, xAxis 数据。 ' selected: false structured_output: schema: additionalProperties: false properties: data: description: series中的data数据,数据用;分隔 type: string title: description: 标题 type: string xAxis: description: xAxis中的data数据,数据用;分隔 type: string required: [] type: object structured_output_enabled: true title: LLM 2 type: llm variables: [] vision: enabled: false height: 89 id: '1748241163811' position: x: 199.30314102594036 y: 629.5077951264029 positionAbsolute: x: 199.30314102594036 y: 629.5077951264029 selected: true sourcePosition: right targetPosition: left type: custom width: 244 - data: answer: ' ### 打印Echarts配置: {{#1748241163811.text#}}' desc: '' selected: false title: 直接回复 3 type: answer variables: [] height: 120 id: '1748241283508' position: x: 519.1372359552149 y: 629.5077951264029 positionAbsolute: x: 519.1372359552149 y: 629.5077951264029 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: desc: '' is_team_authorization: true output_schema: null paramSchemas: - auto_generate: null default: null form: llm human_description: en_US: chart title ja_JP: chart title pt_BR: chart title zh_Hans: 图表的标题 label: en_US: title ja_JP: title pt_BR: title zh_Hans: 标题 llm_description: chart title max: null min: null name: title options: [] placeholder: null precision: null required: true scope: null template: null type: string - auto_generate: null default: null form: llm human_description: en_US: data for generating chart, each number should be separated by ";" ja_JP: data for generating chart, each number should be separated by ";" pt_BR: data for generating chart, each number should be separated by ";" zh_Hans: 用于生成柱状图的数据,每个数字之间用 ";" 分隔 label: en_US: data ja_JP: data pt_BR: data zh_Hans: 数据 llm_description: data for generating bar chart, data should be a string contains a list of numbers like "1;2;3;4;5" max: null min: null name: data options: [] placeholder: null precision: null required: true scope: null template: null type: string - auto_generate: null default: null form: llm human_description: en_US: X axis for chart, each text should be separated by ";" ja_JP: X axis for chart, each text should be separated by ";" pt_BR: X axis for chart, each text should be separated by ";" zh_Hans: 柱状图的 x 轴,每个文本之间用 ";" 分隔 label: en_US: X Axis ja_JP: X Axis pt_BR: X Axis zh_Hans: x 轴 llm_description: x axis for bar chart, x axis should be a string contains a list of texts like "a;b;c;1;2" in order to match the data max: null min: null name: x_axis options: [] placeholder: null precision: null required: true scope: null template: null type: string params: data: '' title: '' x_axis: '' provider_id: langgenius/echarts/echarts provider_name: langgenius/echarts/echarts provider_type: builtin selected: false title: 柱状图 tool_configurations: {} tool_description: 柱状图 tool_label: 柱状图 tool_name: bar_chart tool_parameters: data: type: mixed value: '{{#1748241163811.structured_output.data#}}' title: type: mixed value: '{{#1748241163811.structured_output.title#}}' x_axis: type: mixed value: '{{#1748241163811.structured_output.xAxis#}}' type: tool height: 53 id: '1748241638404' position: x: 885.2461994482006 y: 629.5077951264029 positionAbsolute: x: 885.2461994482006 y: 629.5077951264029 selected: false sourcePosition: right targetPosition: left type: custom width: 244 - data: answer: ' ### echarts图表显示: {{#1748241638404.text#}}' desc: '' selected: false title: 显示图表 type: answer variables: [] height: 120 id: '1748242416972' position: x: 216.86096089523693 y: 887.581433467046 positionAbsolute: x: 216.86096089523693 y: 887.581433467046 selected: false sourcePosition: right targetPosition: left type: custom width: 244 viewport: x: 272.23673982535047 y: 178.98752872388164 zoom: 0.7578582832551991
============ 欢迎各位老板打赏~ ===========

