大模型部署以及案例应用(windows+wsl+dify+mysql+Ollama+Xinference)
- 1.wsl 安装
 - ①安装wsl
 - ②测试以及更新
 - ③安装Ubuntu系统
 - 查看系统以及版本
 - 安装Ubuntu系统
 - 进入Ubuntu系统
 
- 2、docker安装
 - ①下载安装包
 - ②安装
 - ③docker配置
 
- 3、安装dify
 - ①下载dify
 - ②安装
 - ③生成.env 配置文件
 - ④安装dify
 - ⑤打开dify
 
- 4.安装ollama
 - ①下载ollama
 - ②安装ollama
 - ③搜索模型
 - ④下载模型
 - ⑤运行模型
 
- 5、dify与ollama模型对接
 - ①在dify安装ollama
 - ②配置模型
 
- 6、安装conda
 - ①选择对应的版本进行下载。
 - ②修改配置和环境变量
 
- 7、安装配置Xinference
 - ①在cmd创建conda环境
 - ②安装相关依赖
 - ③进行安装以及启动
 - 安装
 - 启动
 - xinference启动效果:
 
- ④启动模型
 - ⑤xinference与dify对接
 - 安装xinference
 - 添加模型
 
- 8、插件的应用
 - 我使用的一些插件
 - 插件下载与安装
 - 也可以通过dify的marketplace直接安装,我测试下载之后安装要快很多。
 
- 9、应用
 - ①生成工具
 - 创建工作流
 - dify发布为工具
 - 补充
 
- ②工作流
 - 测试效果
 - 用户表结构
 
- 10 总结
 - 模型里的SYSTEM 示例
 
1.wsl 安装
①安装wsl
控制面板–程序–打开启用或关闭windows功能-勾选“使用于Linux的Windows子系统”
 
②测试以及更新
打开cmd,输入wsl --update,若出现“已安装最新版本的适用于 Linux 的 Windows 子系统。”,则无需更新,否则自动更新
 
③安装Ubuntu系统
查看系统以及版本

安装Ubuntu系统
在cmd里面输入:wsl --install -d Ubuntu-24.04 进行安装
 
进入Ubuntu系统
方式一:在Windows系统开始搜索Ubuntu-22.04,点击系统管理运行进入
 方式二:在CMD里面执行 wsl -d Ubuntu-22.04 进入
 
2、docker安装
①下载安装包
去https://www.docker.com/下载exe的安装包
②安装
在CMD里面执行"D:\AI\Docker\Docker Desktop Installer.exe" install --installation-dir=“D:\Docker”,我制定了安装目录的。
 
③docker配置
docker一般需要配置两个:
 一个是镜像存放位置,二是docker引擎

 
{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "default-runtime": "nvidia",
  "experimental": false,
  "registry-mirrors": [
    "https://docker-0.unsee.tech",
    "https://docker.1ms.run",
    "https://hub.rat.dev",
    "https://docker.1panel.live",
    "https://hub.rat.dev",
    "https://proxy.1panel.live",
    "https://ghcr.nju.edu.cn",
    "https://docker.registry.cyou",
    "https://dockercf.jsdelivr.fyi",
    "https://docker.rainbond.cc",
    "https://registry.cn-shenzhen.aliyuncs.com",
    "https://dockertest.jsdelivr.fyi",
    "https://mirror.aliyuncs.com",
    "https://mirror.baidubce.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://docker.mirrors.sjtug.sjtu.edu.cn",
    "https://mirror.iscas.ac.cn",
    "https://docker.nju.edu.cn",
    "https://docker.m.daocloud.io",
    "https://dockerproxy.com",
    "https://docker.jsdelivr.fyi",
    "https://docker-cf.registry.cyou",
    "https://hub.docker.com/"
  ],
  "runtimes": {
    "nvidia": {
      "path": "nvidia-container-runtime",
      "runtimeArgs": []
    }
  }
}
 
3、安装dify
①下载dify
下载地址:https://gitcode.com/gh_mirrors/di/dify
②安装
先解压,然后进入安装目录,例如我的进入指令:cd/d E:\dify-main\docker
 
③生成.env 配置文件
dify默认端口是80,如果要修改,则修改.env里面的NGINX_PORT=80 和 EXPOSE_NGINX_PORT=80 两个端口号
 
④安装dify

⑤打开dify
如果默认是80端口,则输入127.0.0.1或者localhost都可以打开
 
4.安装ollama
①下载ollama
在https://ollama.com/download进行下载
②安装ollama
安装到其他盘,可以参照:windows部署deepseek与dify
③搜索模型
可以在https://ollama.com/search,进行查找模型,并复制模型名称。
 
 
④下载模型
在cmd输入:ollama run deepseek-r1:7b,
 注意:
 大一些的模型对显卡要求比较高,下载后如果满足不了最低要求,则运行不了。
 下载模型可以中断,下次输入下载指令可以继续下载
 
⑤运行模型
运行模型治理跟下载一样:ollama run deepseek-r1:7b
 
 查看ollama其他指令可以输入:ollama -h
 
5、dify与ollama模型对接
注意docker、Ubuntu、ollama需运行起来
①在dify安装ollama
点击用户头像,点击设置–模型供应商,搜索ollama,并进行安装ollama
 
 
②配置模型
在模型供应商选择ollama,点击添加模型
http://host.docker.internal:11434
 

 
 模型的类型是根据图标识选择的
 
6、安装conda
①选择对应的版本进行下载。
下载地址:ttps://www.anaconda.com/download/success
 下载完成之后双击运行.exe文件,然后下一步就行,安装完成之后,进行系统环境变量配置。
②修改配置和环境变量
编辑path系统变量,根据实际安装路径进行配置:
E:\anaconda3
E:\anaconda3\Scripts 
E:\anaconda3\Library\mingw-w64\bin
E:\anaconda3\Library\bin
 
打开cmd命令窗口,输入 conda --version命令,验证是否配置成功。若成功则会显示具体的版本号。修改Anaconda默认环境保存路径和镜像源:
 在C:\Users\Dynasty,找到.condarc,
 删除原先内容,进行以下配置。
envs_dirs:
  - E:\Anaconda_envs\envs
pkgs_dirs:
  - E:\Anaconda_envs\pkgs
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - https://repo.anaconda.com/pkgs/msys2
  - defaults
show_channel_urls: true
 
在命令窗口中执行conda info命令,我们就可以看到修改后的配置。
 
7、安装配置Xinference
参考了Windows下安装部署Xinference
①在cmd创建conda环境
conda create xinference
 conda activate xinference
②安装相关依赖
conda install python=3.12
 conda install nodejs
 pip install torch
 
③进行安装以及启动
安装
pip install xinference[all]  -i https://pypi.tuna.tsinghua.edu.cn/simple
 
指定镜像 -i https://pypi.tuna.tsinghua.edu.cn/simple
 
启动
xinference-local --host 192.168.0.104 --port 9997
 
不要用0.0.0.0,启动会报错,192.168.0.104为本机ip地址
 
xinference启动效果:

④启动模型
选择你需要的模型,点击启动
 
⑤xinference与dify对接
参照第5点打开方式
安装xinference

添加模型

 说明:为什么要安装xinference,dify没有
 
 这一类的模型。
8、插件的应用
我使用的一些插件
注意database插件的注册链接:
mysql+pymysql://root:root@168.192.0.107:3306/ssm
 

插件下载与安装
通过插件下载网址 下载插件
 下载后通过安装插件–本地插件–选择插件进行安装
 
也可以通过dify的marketplace直接安装,我测试下载之后安装要快很多。

9、应用
①生成工具
创建工作流

dify发布为工具
注意:里面的流程是根据实际情况进行操作!有一些人通过这儿设置数据查询工具,然后引入到agent里面,会报错。
 
注意:里面的流程是根据实际情况进行操作!有一些人通过这儿设置数据查询工具,然后引入到agent里面,会报错。
 一般分为几种情况:
 一是:模型太小的原因
 二是:引入的知识库的原因
 三是:提示词的原因,提示词要越详细越好
 四是:没有对引入的对话进行清洗和过滤,因为数据查询仅仅是查询sql,而不包含其他文字性内容
 五是:就是我也没有找到原因(有知道的朋友,可以告诉我一下),工具单独测试没有问题
{"data_query": "tool invoke error: Instance <Account at 0x71e62cd38dd0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/20/bhk3)"}
 


补充
采用现有的database.SQL Execute插件,可以查询出来数据。
 
 说明:
 0-0数据字典为表结构
 0-0 提示词用AI实时查询数据库
【角色设定】
您是一位资深数据库专家,擅长根据业务需求将自然语言精准转换为符合规范的SQL语句。您具有以下核心能力:
1. 精通关系型数据库设计,尤其熟悉MySQL语法
2. 深入理解当前业务系统的表结构
[上下文]
3. 能准确识别业务需求中的隐藏条件
4. 熟悉SQL性能优化和事务控制
【输入处理流程】
1. 结构确认:先验证涉及的表是否存在,检查字段名是否准确
2. 关联分析:确认多表关联时的连接条件是否正确
3. 条件推导:将模糊的业务描述转化为精确的WHERE条件
4. 异常处理:识别可能存在的逻辑矛盾或性能陷阱
【输出要求】
输出sql中不要添加任何注释信息
采用如下格式返回结果:
[符合ANSI标准的SQL语句]
根据输出的SQL,例如:
select * from users
调用工具查询数据,并返回结果
 
②工作流
根据DY设置的一个工作流
 
测试效果

 以下是工作的yml文件内容,新建空白yml文件,拷贝代码并放入里面保存。在diy进行引入即可
 
app:
  description: 测试模型
  icon: 🤖
  icon_background: '#FFEAD5'
  mode: advanced-chat
  name: 模型测试
  use_icon_as_answer_icon: false
dependencies:
- current_identifier: null
  type: marketplace
  value:
    marketplace_plugin_unique_identifier: langgenius/ollama:0.0.6@7d66a960a68cafdcdf5589fdf5d01a995533f956853c69c54eddcf797006fa37
- current_identifier: null
  type: package
  value:
    plugin_unique_identifier: jaguarliuu/rookie_text2data:0.3.0@59a0ef957f535edcc661369a3edc3894ce4cd8b8063b296b699ff55c5f6d262d
- current_identifier: null
  type: package
  value:
    plugin_unique_identifier: jaguarliuu/rookie_data_alchemy:0.0.4@2be34d32b23be1a447f7822b77dc54462155710ab1cd38d118e562fddbc13cdc
- current_identifier: null
  type: package
  value:
    plugin_unique_identifier: bowenliang123/md_exporter:1.4.100@71e015c278af8ae41b80f88a72f03ef92ad01b8db0c3676eafd3f998c4d57601
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: ''
    retriever_resource:
      enabled: true
    sensitive_word_avoidance:
      enabled: false
    speech_to_text:
      enabled: false
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
      language: ''
      voice: ''
  graph:
    edges:
    - data:
        sourceType: start
        targetType: llm
      id: 1748696326544-llm
      source: '1748696326544'
      sourceHandle: source
      target: llm
      targetHandle: target
      type: custom
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: tool
      id: llm-source-1748696528530-target
      source: llm
      sourceHandle: source
      target: '1748696528530'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: tool
        targetType: tool
      id: 1748696528530-source-1748696624432-target
      source: '1748696528530'
      sourceHandle: source
      target: '1748696624432'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: tool
        targetType: if-else
      id: 1748696624432-source-1748696664775-target
      source: '1748696624432'
      sourceHandle: source
      target: '1748696664775'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: if-else
        targetType: llm
      id: 1748696664775-true-1748696729922-target
      source: '1748696664775'
      sourceHandle: 'true'
      target: '1748696729922'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: llm
      id: 1748696729922-source-1748696811184-target
      source: '1748696729922'
      sourceHandle: source
      target: '1748696811184'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: tool
      id: 1748696811184-source-1748696899575-target
      source: '1748696811184'
      sourceHandle: source
      target: '1748696899575'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: tool
        targetType: answer
      id: 1748696899575-source-answer-target
      source: '1748696899575'
      sourceHandle: source
      target: answer
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: if-else
        targetType: llm
      id: 1748696664775-6f64ec9a-f939-412f-b673-2bc1a852d5ce-1748697147705-target
      source: '1748696664775'
      sourceHandle: 6f64ec9a-f939-412f-b673-2bc1a852d5ce
      target: '1748697147705'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: tool
      id: 1748697147705-source-1748697966459-target
      source: '1748697147705'
      sourceHandle: source
      target: '1748697966459'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: tool
        targetType: answer
      id: 1748697966459-source-1748698000525-target
      source: '1748697966459'
      sourceHandle: source
      target: '1748698000525'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: if-else
        targetType: llm
      id: 1748696664775-false-1748698025100-target
      source: '1748696664775'
      sourceHandle: 'false'
      target: '1748698025100'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: answer
      id: 1748698025100-source-1748698346189-target
      source: '1748698025100'
      sourceHandle: source
      target: '1748698346189'
      targetHandle: target
      type: custom
      zIndex: 0
    nodes:
    - data:
        desc: ''
        selected: false
        title: 开始
        type: start
        variables: []
      height: 53
      id: '1748696326544'
      position:
        x: 30
        y: 361.5
      positionAbsolute:
        x: 30
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        context:
          enabled: false
          variable_selector: []
        desc: ''
        memory:
          query_prompt_template: '{{#sys.query#}}'
          role_prefix:
            assistant: ''
            user: ''
          window:
            enabled: false
            size: 10
        model:
          completion_params: {}
          mode: chat
          name: qwen2.5vl:7b
          provider: langgenius/ollama/ollama
        prompt_template:
        - id: 48eac4f7-06d7-4a91-b28d-112d00f9bbf0
          role: system
          text: "#角色\n你是一位文字提炼专家\n#任务\n负责把用户的查询数据需求进行提炼和总结,抓取关键数据查询文字,去掉和数据查询无关的内容,只保留提炼查询数据的文字\n\
            #输出\n注意事项:\n所有非聚合字段必须出现在GROUP BY中,只输出SQL语句,不要解释。输出示例:\n查询用户信息:\nselect\
            \  *  from users\n查询用户数:\nselect  count(1) from users\n查询大于22岁的用户:\n select\
            \  * from users where age>22\n查询用户的姓名:\nselect name from users\n统计年龄大22岁的人数:\n\
            select count(1) from users where age>22\n统计绿色指标表以及指标总得分:\nselect oname,sum(score)\
            \ from green_item group by oname"
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
          enabled: false
      height: 89
      id: llm
      position:
        x: 333
        y: 361.5
      positionAbsolute:
        x: 333
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        answer: '{{#1748696899575.text#}}'
        desc: ''
        selected: false
        title: 直接回复
        type: answer
        variables: []
      height: 104
      id: answer
      position:
        x: 2454
        y: 361.5
      positionAbsolute:
        x: 2454
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        desc: ''
        is_team_authorization: true
        output_schema: null
        paramSchemas:
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database type
            ja_JP: Database type
            pt_BR: Database type
            zh_Hans: 数据库类型
          label:
            en_US: Database type
            ja_JP: Database type
            pt_BR: Database type
            zh_Hans: 数据库类型
          llm_description: Database type
          max: null
          min: null
          name: db_type
          options:
          - label:
              en_US: MySQL
              ja_JP: MySQL
              pt_BR: MySQL
              zh_Hans: MySQL
            value: mysql
          - label:
              en_US: PostgreSQL
              ja_JP: PostgreSQL
              pt_BR: PostgreSQL
              zh_Hans: PostgreSQL
            value: postgresql
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: select
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: limit
            ja_JP: limit
            pt_BR: limit
            zh_Hans: SQL返回数据量限制
          label:
            en_US: limit
            ja_JP: limit
            pt_BR: limit
            zh_Hans: SQL返回数据量限制
          llm_description: limit
          max: 1000
          min: 1
          name: limit
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: number
        - auto_generate: null
          default: json
          form: form
          human_description:
            en_US: result_format
            ja_JP: result_format
            pt_BR: result_format
            zh_Hans: 返回数据格式
          label:
            en_US: result_format
            ja_JP: result_format
            pt_BR: result_format
            zh_Hans: 返回数据格式
          llm_description: result_format
          max: null
          min: null
          name: result_format
          options:
          - label:
              en_US: JSON
              ja_JP: JSON
              pt_BR: JSON
              zh_Hans: JSON
            value: json
          - label:
              en_US: TEXT
              ja_JP: TEXT
              pt_BR: TEXT
              zh_Hans: TEXT
            value: text
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: select
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database ip/host
            ja_JP: Database ip/host
            pt_BR: Database ip/host
            zh_Hans: 数据库IP/域名
          label:
            en_US: Database ip/host
            ja_JP: Database ip/host
            pt_BR: Database ip/host
            zh_Hans: 数据库IP/域名
          llm_description: Database ip/host
          max: null
          min: null
          name: host
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database port
            ja_JP: Database port
            pt_BR: Database port
            zh_Hans: 数据库端口
          label:
            en_US: Database port
            ja_JP: Database port
            pt_BR: Database port
            zh_Hans: 数据库端口
          llm_description: Database port
          max: 65535
          min: 1
          name: port
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: number
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database name
            ja_JP: Database name
            pt_BR: Database name
            zh_Hans: 数据库名称
          label:
            en_US: Database name
            ja_JP: Database name
            pt_BR: Database name
            zh_Hans: 数据库名称
          llm_description: Database name
          max: null
          min: null
          name: db_name
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: table_names
            ja_JP: table_names
            pt_BR: table_names
            zh_Hans: 数据表名称
          label:
            en_US: table_names
            ja_JP: table_names
            pt_BR: table_names
            zh_Hans: 数据表名称
          llm_description: table_names
          max: null
          min: null
          name: table_names
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: Schema name
            ja_JP: Schema name
            pt_BR: Schema name
            zh_Hans: 数据库Schema PGSQL用户选填,默认为public
          label:
            en_US: Schema name
            ja_JP: Schema name
            pt_BR: Schema name
            zh_Hans: 数据库Schema PGSQL用户选填,默认为public
          llm_description: Schema name
          max: null
          min: null
          name: schema_name
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Username
            ja_JP: Username
            pt_BR: Username
            zh_Hans: 用户名
          label:
            en_US: Username
            ja_JP: Username
            pt_BR: Username
            zh_Hans: 用户名
          llm_description: Username
          max: null
          min: null
          name: username
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Password
            ja_JP: Password
            pt_BR: Password
            zh_Hans: 密码
          label:
            en_US: Password
            ja_JP: Password
            pt_BR: Password
            zh_Hans: 密码
          llm_description: Password
          max: null
          min: null
          name: password
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: secret-input
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: LLM model for text2data.
            ja_JP: LLM model for text2data.
            pt_BR: LLM model for text2data.
            zh_Hans: LLM model for text2data.
          label:
            en_US: Model
            ja_JP: Model
            pt_BR: Model
            zh_Hans: 模型
          llm_description: LLM model for text2data.
          max: null
          min: null
          name: model
          options: []
          placeholder: null
          precision: null
          required: true
          scope: llm
          template: null
          type: model-selector
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: Fetching data from the database using natural language.
            ja_JP: Fetching data from the database using natural language.
            pt_BR: Fetching data from the database using natural language.
            zh_Hans: Fetching data from the database using natural language.
          label:
            en_US: Query string
            ja_JP: Query string
            pt_BR: Query string
            zh_Hans: 查询语句
          llm_description: Fetching data from the database using natural language.
          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: custom_prompt
            ja_JP: custom_prompt
            pt_BR: custom_prompt
            zh_Hans: 自定义提示
          label:
            en_US: custom_prompt
            ja_JP: custom_prompt
            pt_BR: custom_prompt
            zh_Hans: 自定义提示
          llm_description: custom_prompt
          max: null
          min: null
          name: custom_prompt
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: with_comment
            ja_JP: with_comment
            pt_BR: with_comment
            zh_Hans: 是否包含注释
          label:
            en_US: with_comment
            ja_JP: with_comment
            pt_BR: with_comment
            zh_Hans: 是否包含注释
          llm_description: with_comment
          max: null
          min: null
          name: with_comment
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: boolean
        params:
          custom_prompt: ''
          db_name: ''
          db_type: ''
          host: ''
          limit: ''
          model: ''
          password: ''
          port: ''
          query: ''
          result_format: ''
          schema_name: ''
          table_names: ''
          username: ''
          with_comment: ''
        provider_id: jaguarliuu/rookie_text2data/rookie_text2data
        provider_name: jaguarliuu/rookie_text2data/rookie_text2data
        provider_type: builtin
        selected: false
        title: rookie_text2data
        tool_configurations:
          db_name: ssm
          db_type: mysql
          host: 192.168.0.107
          limit: null
          model:
            completion_params: {}
            mode: chat
            model: qwen2.5vl:7b
            model_type: llm
            provider: langgenius/ollama/ollama
            type: model-selector
          password: jiang1987
          port: 3306
          result_format: text
          username: ssm
          with_comment: 1
        tool_description: 使用自然语言从MySQL获取数据
        tool_label: rookie_text2data
        tool_name: rookie_text2data
        tool_parameters:
          custom_prompt:
            type: mixed
            value: '绿色指标表表注释
              表名称:green_item
              -id:主键ID,int
              -oname:一级指标,varchar(255)
              -sname:二级指标,varchar(255)
              -tname:三级指标,varchar(255)
              -score:绿色分值,int
              事项表表注释
              表名称:item_dic
              -id:字典主键,int
              -tid:上级主键,int
              -name:事项名称,varchar(255)
              -item_name:细项名称,varchar(255)
              -score:等分,int
              ##菜单表表注释
              表名称:menus
              -mid:菜单主键,int
              -mfid:上级主键,int
              -mname:菜单名称,varchar(255)
              -murl:菜单链接,varchar(255)
              角色表表注释
              表名称:roles
              -rid:角色主键,int
              -rname:角色名称,varchar(255)
              角色表表注释
              表名称:users
              -id:主键ID,int
              -name:姓名,varchar(255)
              -age:年龄,int
              注意事项:
              - 如有分组统计,请使用SUM、AVG等聚合函数,不要直接用原始字段。
              - 所有非聚合字段必须出现在GROUP BY中。
              - 只输出SQL语句,不要解释。'
          query:
            type: mixed
            value: '{{#llm.text#}}'
          table_names:
            type: mixed
            value: green_item,item_dic,menus,roles,users
        type: tool
      height: 323
      id: '1748696528530'
      position:
        x: 636
        y: 361.5
      positionAbsolute:
        x: 636
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        desc: ''
        is_team_authorization: true
        output_schema: null
        paramSchemas:
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database type
            ja_JP: Database type
            pt_BR: Database type
            zh_Hans: 数据库类型
          label:
            en_US: Database type
            ja_JP: Database type
            pt_BR: Database type
            zh_Hans: 数据库类型
          llm_description: Database type
          max: null
          min: null
          name: db_type
          options:
          - label:
              en_US: MySQL
              ja_JP: MySQL
              pt_BR: MySQL
              zh_Hans: MySQL
            value: mysql
          - label:
              en_US: PostgreSQL
              ja_JP: PostgreSQL
              pt_BR: PostgreSQL
              zh_Hans: PostgreSQL
            value: postgresql
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: select
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database ip/host
            ja_JP: Database ip/host
            pt_BR: Database ip/host
            zh_Hans: 数据库IP/域名
          label:
            en_US: Database ip/host
            ja_JP: Database ip/host
            pt_BR: Database ip/host
            zh_Hans: 数据库IP/域名
          llm_description: Database ip/host
          max: null
          min: null
          name: host
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database port
            ja_JP: Database port
            pt_BR: Database port
            zh_Hans: 数据库端口
          label:
            en_US: Database port
            ja_JP: Database port
            pt_BR: Database port
            zh_Hans: 数据库端口
          llm_description: Database port
          max: 65535
          min: 1
          name: port
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: number
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Database name
            ja_JP: Database name
            pt_BR: Database name
            zh_Hans: 数据库名称
          label:
            en_US: Database name
            ja_JP: Database name
            pt_BR: Database name
            zh_Hans: 数据库名称
          llm_description: Database name
          max: null
          min: null
          name: db_name
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Username
            ja_JP: Username
            pt_BR: Username
            zh_Hans: 用户名
          label:
            en_US: Username
            ja_JP: Username
            pt_BR: Username
            zh_Hans: 用户名
          llm_description: Username
          max: null
          min: null
          name: username
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: Password
            ja_JP: Password
            pt_BR: Password
            zh_Hans: 密码
          label:
            en_US: Password
            ja_JP: Password
            pt_BR: Password
            zh_Hans: 密码
          llm_description: Password
          max: null
          min: null
          name: password
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: secret-input
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: Schema name
            ja_JP: Schema name
            pt_BR: Schema name
            zh_Hans: 数据库Schema PGSQL用户选填,默认为public
          label:
            en_US: Schema name
            ja_JP: Schema name
            pt_BR: Schema name
            zh_Hans: 数据库Schema PGSQL用户选填,默认为public
          llm_description: Schema name
          max: null
          min: null
          name: schema
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: Fetching data from the database using natural language.
            ja_JP: Fetching data from the database using natural language.
            pt_BR: Fetching data from the database using natural language.
            zh_Hans: Fetching data from the database using natural language.
          label:
            en_US: SQL string
            ja_JP: SQL string
            pt_BR: SQL string
            zh_Hans: 待执行的 SQL 语句
          llm_description: Fetching data from the database using natural language.
          max: null
          min: null
          name: sql
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: json
          form: form
          human_description:
            en_US: result_format
            ja_JP: result_format
            pt_BR: result_format
            zh_Hans: 返回数据格式
          label:
            en_US: result_format
            ja_JP: result_format
            pt_BR: result_format
            zh_Hans: 返回数据格式
          llm_description: result_format
          max: null
          min: null
          name: result_format
          options:
          - label:
              en_US: JSON
              ja_JP: JSON
              pt_BR: JSON
              zh_Hans: JSON
            value: json
          - label:
              en_US: TEXT
              ja_JP: TEXT
              pt_BR: TEXT
              zh_Hans: TEXT
            value: text
          - label:
              en_US: CSV
              ja_JP: CSV
              pt_BR: CSV
              zh_Hans: CSV
            value: csv
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: select
        params:
          db_name: ''
          db_type: ''
          host: ''
          password: ''
          port: ''
          result_format: ''
          schema: ''
          sql: ''
          username: ''
        provider_id: jaguarliuu/rookie_text2data/rookie_text2data
        provider_name: jaguarliuu/rookie_text2data/rookie_text2data
        provider_type: builtin
        selected: false
        title: rookie_excute_sql
        tool_configurations:
          db_name: ssm
          db_type: mysql
          host: 192.168.0.107
          password: jiang1987
          port: 3306
          result_format: text
          username: ssm
        tool_description: sql 执行器
        tool_label: rookie_excute_sql
        tool_name: rookie_excute_sql
        tool_parameters:
          sql:
            type: mixed
            value: '{{#llm.text#}}'
        type: tool
      height: 245
      id: '1748696624432'
      position:
        x: 939
        y: 361.5
      positionAbsolute:
        x: 939
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        cases:
        - case_id: 'true'
          conditions:
          - comparison_operator: contains
            id: 0e10be77-29c5-466c-b950-07548022a669
            value: 图
            varType: string
            variable_selector:
            - sys
            - query
          id: 'true'
          logical_operator: and
        - case_id: 6f64ec9a-f939-412f-b673-2bc1a852d5ce
          conditions:
          - comparison_operator: contains
            id: f52c2ed9-0a5d-4e8f-8bff-01b13742d267
            value: excel
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 4b0a8f85-7221-4d02-acf4-f709c707d7fb
            value: Excel
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 64c7dc5d-2c3c-4786-8cec-f7db37057475
            value: EXCEL
            varType: string
            variable_selector:
            - sys
            - query
          id: 6f64ec9a-f939-412f-b673-2bc1a852d5ce
          logical_operator: and
        desc: ''
        selected: false
        title: 条件分支
        type: if-else
      height: 225
      id: '1748696664775'
      position:
        x: 1242
        y: 361.5
      positionAbsolute:
        x: 1242
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        context:
          enabled: false
          variable_selector: []
        desc: ''
        model:
          completion_params: {}
          mode: chat
          name: qwen2.5vl:7b
          provider: langgenius/ollama/ollama
        prompt_template:
        - id: 7f02bbf8-3196-4a90-9405-482a585afcc8
          role: system
          text: '#任务
            根据用户需求,以及数据内容,自行判断哪种图表类型适合
            #输出
            只输入你推荐的图表类型名称,从以下类型中选择一个输出:柱状图、折线图、饼图,散点图,矩形树图'
        - id: 5c0fe9be-9e09-4679-b247-aeab12cdc8bb
          role: user
          text: '用户问题:{{#sys.query#}}
            数据库数据:{{#1748696528530.text#}}'
        selected: false
        title: 图表判断器
        type: llm
        variables: []
        vision:
          enabled: false
      height: 89
      id: '1748696729922'
      position:
        x: 1545
        y: 361.5
      positionAbsolute:
        x: 1545
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        context:
          enabled: false
          variable_selector: []
        desc: ''
        model:
          completion_params: {}
          mode: chat
          name: qwen2.5vl:7b
          provider: langgenius/ollama/ollama
        prompt_template:
        - id: 802dc976-d7c7-4222-b8a8-2ca473820037
          role: system
          text: '#任务
            请将用户提供的文档内容转化为标准的json内容,不包含“josn”的标签,只输出标准josn'
        - id: 67ebe4d2-123c-499c-8d8b-dc20c34f7600
          role: user
          text: 用户提供的文档内容:{{#1748696624432.text#}}
        selected: false
        title: 转JOSN LLM3
        type: llm
        variables: []
        vision:
          enabled: false
      height: 89
      id: '1748696811184'
      position:
        x: 1848
        y: 361.5
      positionAbsolute:
        x: 1848
        y: 361.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        desc: ''
        is_team_authorization: true
        output_schema: null
        paramSchemas:
        - auto_generate: null
          default: null
          form: form
          human_description:
            en_US: LLM model for rookie_data_alchemy.
            ja_JP: LLM model for rookie_data_alchemy.
            pt_BR: LLM model for rookie_data_alchemy.
            zh_Hans: LLM model for rookie_data_alchemy.
          label:
            en_US: Model
            ja_JP: Model
            pt_BR: Model
            zh_Hans: 模型
          llm_description: LLM model for text2data.
          max: null
          min: null
          name: model
          options: []
          placeholder: null
          precision: null
          required: true
          scope: llm
          template: null
          type: model-selector
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: wait for data
            ja_JP: wait for data
            pt_BR: wait for data
            zh_Hans: 待处理的数据,建议为json格式或md
          label:
            en_US: data
            ja_JP: data
            pt_BR: data
            zh_Hans: 待处理的数据,建议为json格式或md
          llm_description: wait for data
          max: null
          min: null
          name: data
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: title
            ja_JP: title
            pt_BR: title
            zh_Hans: 图表标题,不填则大模型推理生成
          label:
            en_US: title
            ja_JP: title
            pt_BR: title
            zh_Hans: 图表标题,不填则大模型推理生成
          llm_description: title
          max: null
          min: null
          name: title
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: chart type
            ja_JP: chart type
            pt_BR: chart type
            zh_Hans: 图表类型
          label:
            en_US: chart type
            ja_JP: chart type
            pt_BR: chart type
            zh_Hans: 图表类型
          llm_description: chart type
          max: null
          min: null
          name: chart_type
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: custom requirements
            ja_JP: custom requirements
            pt_BR: custom requirements
            zh_Hans: 自定义需求
          label:
            en_US: custom requirements
            ja_JP: custom requirements
            pt_BR: custom requirements
            zh_Hans: 自定义需求
          llm_description: custom requirements
          max: null
          min: null
          name: custom_requirements
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        params:
          chart_type: ''
          custom_requirements: ''
          data: ''
          model: ''
          title: ''
        provider_id: jaguarliuu/rookie_data_alchemy/rookie_data_alchemy
        provider_name: jaguarliuu/rookie_data_alchemy/rookie_data_alchemy
        provider_type: builtin
        selected: false
        title: rookie_data_alchemy
        tool_configurations:
          model:
            completion_params: {}
            mode: chat
            model: deepseek-r1:7b
            model_type: llm
            provider: langgenius/ollama/ollama
            type: model-selector
        tool_description: Visualizing structured data as charts
        tool_label: rookie_data_alchemy
        tool_name: rookie_data_alchemy
        tool_parameters:
          chart_type:
            type: mixed
            value: '{{#1748696729922.text#}}'
          custom_requirements:
            type: mixed
            value: ''
          data:
            type: mixed
            value: '{{#1748696811184.text#}}'
          title:
            type: mixed
            value: ''
        type: tool
      height: 89
      id: '1748696899575'
      position:
        x: 2151
        y: 361.5
      positionAbsolute:
        x: 2151
        y: 361.5
      selected: true
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        context:
          enabled: false
          variable_selector: []
        desc: ''
        model:
          completion_params: {}
          mode: chat
          name: qwen2.5vl:7b
          provider: langgenius/ollama/ollama
        prompt_template:
        - id: 2d5be626-1a76-4d04-bc8c-2f57cae3fe96
          role: system
          text: '#任务
            把数据库数据转化为表格类型的markdown文本内容,并把表头翻译为中文
            #输出
            只输出转化后的表格类型的markdown,不是要“''“markdown\n”''”等语言标签,只输出标准的markdown表格'
        - id: 9d64935a-8b00-4d2c-ad97-f6a46a113a36
          role: user
          text: ''
        selected: false
        title: 转markdown格式
        type: llm
        variables: []
        vision:
          enabled: false
      height: 89
      id: '1748697147705'
      position:
        x: 1545
        y: 498
      positionAbsolute:
        x: 1545
        y: 498
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        desc: ''
        is_team_authorization: true
        output_schema: null
        paramSchemas:
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: Markdown table text
            ja_JP: Markdown table text
            pt_BR: Markdown table text
            zh_Hans: Markdown格式文本,必须为Markdown表格格式,可包含多个表格
          label:
            en_US: Markdown text
            ja_JP: Markdown text
            pt_BR: Markdown text
            zh_Hans: Markdown格式文本
          llm_description: ''
          max: null
          min: null
          name: md_text
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: Filename of the output file
            ja_JP: Filename of the output file
            pt_BR: Filename of the output file
            zh_Hans: 输出文件名
          label:
            en_US: Filename of the output file
            ja_JP: Filename of the output file
            pt_BR: Filename of the output file
            zh_Hans: 输出文件名
          llm_description: ''
          max: null
          min: null
          name: output_filename
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        params:
          md_text: ''
          output_filename: ''
        provider_id: bowenliang123/md_exporter/md_exporter
        provider_name: bowenliang123/md_exporter/md_exporter
        provider_type: builtin
        selected: false
        title: Markdown转XLSX文件
        tool_configurations: {}
        tool_description: 一个用于将Markdown转换为XLSX文件的工具
        tool_label: Markdown转XLSX文件
        tool_name: md_to_xlsx
        tool_parameters:
          md_text:
            type: mixed
            value: '{{#1748697147705.text#}}'
          output_filename:
            type: mixed
            value: ''
        type: tool
      height: 53
      id: '1748697966459'
      position:
        x: 1848
        y: 516
      positionAbsolute:
        x: 1848
        y: 516
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        answer: '{{#sys.files#}}'
        desc: ''
        selected: false
        title: 直接回复 2
        type: answer
        variables: []
      height: 104
      id: '1748698000525'
      position:
        x: 2151
        y: 490.5
      positionAbsolute:
        x: 2151
        y: 490.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        context:
          enabled: false
          variable_selector: []
        desc: ''
        model:
          completion_params: {}
          mode: chat
          name: qwen2.5vl:7b
          provider: langgenius/ollama/ollama
        prompt_template:
        - id: d05a33f6-5888-41db-8533-fbe04d312a19
          role: system
          text: '#角色
            你是一个精通数据处理、分析和总结的大师
            #任务
            你可以根据用户的问题,从提供的数据库中检索相关信息,整合提炼后用精准合适的自然语言来回复用户
            #输出
            1.若用户只是查询数据,则提炼之后直接回复数据即可
            2.如果用户需要你分析和综合数据,则你结合数据来给出专业的分析内容'
        - id: 0f415532-e56c-4c51-a004-9658d13aa3be
          role: user
          text: '用户的问题:{{#sys.query#}}
            数据库数据:{{#1748696624432.text#}}'
        selected: false
        title: LLM 5
        type: llm
        variables: []
        vision:
          enabled: false
      height: 89
      id: '1748698025100'
      position:
        x: 1545
        y: 627
      positionAbsolute:
        x: 1545
        y: 627
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    - data:
        answer: '{{#1748698025100.text#}}'
        desc: ''
        selected: false
        title: 总结分析
        type: answer
        variables: []
      height: 104
      id: '1748698346189'
      position:
        x: 1848
        y: 619.5
      positionAbsolute:
        x: 1848
        y: 619.5
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 243
    viewport:
      x: -964.6500000000001
      y: -95.05000000000001
      zoom: 0.7
 
用户表结构
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`  (
  `id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '姓名',
  `age` int(0) NULL DEFAULT NULL COMMENT '年龄',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户信息' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
 
10 总结
从接触模型以来,也没有几天,不断的通过网上的知识进行研究和学习,文档内容如有不对对请指正。感谢!!!!
 
模型里的SYSTEM 示例
#角色
你是一个专业的数据分析专家,并且精通根据用户的问题、数据表结构进行生成SQL语句进行查询数据库。
#任务
1.负责把用户的查询数据需求进行提炼和总结,抓取关键数据查询文字,去掉和数据查询无关的内容,只保留提炼查询数据的文字
2.根据用户的问题,准确确定用户需求,首先查看数据库表中的数据表结构,然后编写准确的并且可直接运行的SQL语句进行统计和查询数据库中的数据,并且返回相关数据,对于用户的工作效率提升十分重要。
#输出
注意事项:
所有非聚合字段必须出现在GROUP BY中,只输出SQL语句,不要解释。输出示例:
查询用户信息:
select  *  from users
查询用户数:
select  count(1) from users
 
角色定义你模型的作用
 任务:任务一定要写详细、清楚、简洁
 输出:输出的内容进行描述,示例针对sql查询或者调用图表,模型会根据你的示例进行处理,比如查询用户的示例select * from users,如果在对话中输入查询角色信息,则模型自动会调整为select * from roles,但是如果你输入的是展示角色信息,那么就可能模型就识别不了(跟模型理解有关)。
USER和ASSISTANT 待研究







![[ Qt ] | QPushButton常见用法](https://i-blog.csdnimg.cn/direct/334f8a5a97c54445aae4804912a67fcf.png)










