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

初学大模型部署以及案例应用(windows+wsl+dify+mysql+Ollama+Xinference)

大模型部署以及案例应用(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子系统”
打开启用或关闭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-chatname: 模型测试use_icon_as_answer_icon: false
dependencies:
- current_identifier: nulltype: marketplacevalue:marketplace_plugin_unique_identifier: langgenius/ollama:0.0.6@7d66a960a68cafdcdf5589fdf5d01a995533f956853c69c54eddcf797006fa37
- current_identifier: nulltype: packagevalue:plugin_unique_identifier: jaguarliuu/rookie_text2data:0.3.0@59a0ef957f535edcc661369a3edc3894ce4cd8b8063b296b699ff55c5f6d262d
- current_identifier: nulltype: packagevalue:plugin_unique_identifier: jaguarliuu/rookie_data_alchemy:0.0.4@2be34d32b23be1a447f7822b77dc54462155710ab1cd38d118e562fddbc13cdc
- current_identifier: nulltype: packagevalue: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- .SVGallowed_file_types:- imageallowed_file_upload_methods:- local_file- remote_urlenabled: falsefileUploadConfig:audio_file_size_limit: 50batch_count_limit: 5file_size_limit: 15image_file_size_limit: 10video_file_size_limit: 100workflow_file_upload_limit: 10image:enabled: falsenumber_limits: 3transfer_methods:- local_file- remote_urlnumber_limits: 3opening_statement: ''retriever_resource:enabled: truesensitive_word_avoidance:enabled: falsespeech_to_text:enabled: falsesuggested_questions: []suggested_questions_after_answer:enabled: falsetext_to_speech:enabled: falselanguage: ''voice: ''graph:edges:- data:sourceType: starttargetType: llmid: 1748696326544-llmsource: '1748696326544'sourceHandle: sourcetarget: llmtargetHandle: targettype: custom- data:isInIteration: falseisInLoop: falsesourceType: llmtargetType: toolid: llm-source-1748696528530-targetsource: llmsourceHandle: sourcetarget: '1748696528530'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: tooltargetType: toolid: 1748696528530-source-1748696624432-targetsource: '1748696528530'sourceHandle: sourcetarget: '1748696624432'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: tooltargetType: if-elseid: 1748696624432-source-1748696664775-targetsource: '1748696624432'sourceHandle: sourcetarget: '1748696664775'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: if-elsetargetType: llmid: 1748696664775-true-1748696729922-targetsource: '1748696664775'sourceHandle: 'true'target: '1748696729922'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: llmtargetType: llmid: 1748696729922-source-1748696811184-targetsource: '1748696729922'sourceHandle: sourcetarget: '1748696811184'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: llmtargetType: toolid: 1748696811184-source-1748696899575-targetsource: '1748696811184'sourceHandle: sourcetarget: '1748696899575'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: tooltargetType: answerid: 1748696899575-source-answer-targetsource: '1748696899575'sourceHandle: sourcetarget: answertargetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: if-elsetargetType: llmid: 1748696664775-6f64ec9a-f939-412f-b673-2bc1a852d5ce-1748697147705-targetsource: '1748696664775'sourceHandle: 6f64ec9a-f939-412f-b673-2bc1a852d5cetarget: '1748697147705'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: llmtargetType: toolid: 1748697147705-source-1748697966459-targetsource: '1748697147705'sourceHandle: sourcetarget: '1748697966459'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: tooltargetType: answerid: 1748697966459-source-1748698000525-targetsource: '1748697966459'sourceHandle: sourcetarget: '1748698000525'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: if-elsetargetType: llmid: 1748696664775-false-1748698025100-targetsource: '1748696664775'sourceHandle: 'false'target: '1748698025100'targetHandle: targettype: customzIndex: 0- data:isInIteration: falseisInLoop: falsesourceType: llmtargetType: answerid: 1748698025100-source-1748698346189-targetsource: '1748698025100'sourceHandle: sourcetarget: '1748698346189'targetHandle: targettype: customzIndex: 0nodes:- data:desc: ''selected: falsetitle: 开始type: startvariables: []height: 53id: '1748696326544'position:x: 30y: 361.5positionAbsolute:x: 30y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:context:enabled: falsevariable_selector: []desc: ''memory:query_prompt_template: '{{#sys.query#}}'role_prefix:assistant: ''user: ''window:enabled: falsesize: 10model:completion_params: {}mode: chatname: qwen2.5vl:7bprovider: langgenius/ollama/ollamaprompt_template:- id: 48eac4f7-06d7-4a91-b28d-112d00f9bbf0role: systemtext: "#角色\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: falsetitle: LLMtype: llmvariables: []vision:enabled: falseheight: 89id: llmposition:x: 333y: 361.5positionAbsolute:x: 333y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:answer: '{{#1748696899575.text#}}'desc: ''selected: falsetitle: 直接回复type: answervariables: []height: 104id: answerposition:x: 2454y: 361.5positionAbsolute:x: 2454y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:desc: ''is_team_authorization: trueoutput_schema: nullparamSchemas:- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database typeja_JP: Database typept_BR: Database typezh_Hans: 数据库类型label:en_US: Database typeja_JP: Database typept_BR: Database typezh_Hans: 数据库类型llm_description: Database typemax: nullmin: nullname: db_typeoptions:- label:en_US: MySQLja_JP: MySQLpt_BR: MySQLzh_Hans: MySQLvalue: mysql- label:en_US: PostgreSQLja_JP: PostgreSQLpt_BR: PostgreSQLzh_Hans: PostgreSQLvalue: postgresqlplaceholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: select- auto_generate: nulldefault: nullform: formhuman_description:en_US: limitja_JP: limitpt_BR: limitzh_Hans: SQL返回数据量限制label:en_US: limitja_JP: limitpt_BR: limitzh_Hans: SQL返回数据量限制llm_description: limitmax: 1000min: 1name: limitoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: number- auto_generate: nulldefault: jsonform: formhuman_description:en_US: result_formatja_JP: result_formatpt_BR: result_formatzh_Hans: 返回数据格式label:en_US: result_formatja_JP: result_formatpt_BR: result_formatzh_Hans: 返回数据格式llm_description: result_formatmax: nullmin: nullname: result_formatoptions:- label:en_US: JSONja_JP: JSONpt_BR: JSONzh_Hans: JSONvalue: json- label:en_US: TEXTja_JP: TEXTpt_BR: TEXTzh_Hans: TEXTvalue: textplaceholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: select- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database ip/hostja_JP: Database ip/hostpt_BR: Database ip/hostzh_Hans: 数据库IP/域名label:en_US: Database ip/hostja_JP: Database ip/hostpt_BR: Database ip/hostzh_Hans: 数据库IP/域名llm_description: Database ip/hostmax: nullmin: nullname: hostoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database portja_JP: Database portpt_BR: Database portzh_Hans: 数据库端口label:en_US: Database portja_JP: Database portpt_BR: Database portzh_Hans: 数据库端口llm_description: Database portmax: 65535min: 1name: portoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: number- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database nameja_JP: Database namept_BR: Database namezh_Hans: 数据库名称label:en_US: Database nameja_JP: Database namept_BR: Database namezh_Hans: 数据库名称llm_description: Database namemax: nullmin: nullname: db_nameoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_description:en_US: table_namesja_JP: table_namespt_BR: table_nameszh_Hans: 数据表名称label:en_US: table_namesja_JP: table_namespt_BR: table_nameszh_Hans: 数据表名称llm_description: table_namesmax: nullmin: nullname: table_namesoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_description:en_US: Schema nameja_JP: Schema namept_BR: Schema namezh_Hans: 数据库Schema PGSQL用户选填,默认为publiclabel:en_US: Schema nameja_JP: Schema namept_BR: Schema namezh_Hans: 数据库Schema PGSQL用户选填,默认为publicllm_description: Schema namemax: nullmin: nullname: schema_nameoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: formhuman_description:en_US: Usernameja_JP: Usernamept_BR: Usernamezh_Hans: 用户名label:en_US: Usernameja_JP: Usernamept_BR: Usernamezh_Hans: 用户名llm_description: Usernamemax: nullmin: nullname: usernameoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: formhuman_description:en_US: Passwordja_JP: Passwordpt_BR: Passwordzh_Hans: 密码label:en_US: Passwordja_JP: Passwordpt_BR: Passwordzh_Hans: 密码llm_description: Passwordmax: nullmin: nullname: passwordoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: secret-input- auto_generate: nulldefault: nullform: formhuman_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: Modelja_JP: Modelpt_BR: Modelzh_Hans: 模型llm_description: LLM model for text2data.max: nullmin: nullname: modeloptions: []placeholder: nullprecision: nullrequired: truescope: llmtemplate: nulltype: model-selector- auto_generate: nulldefault: nullform: llmhuman_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 stringja_JP: Query stringpt_BR: Query stringzh_Hans: 查询语句llm_description: Fetching data from the database using natural language.max: nullmin: nullname: queryoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_description:en_US: custom_promptja_JP: custom_promptpt_BR: custom_promptzh_Hans: 自定义提示label:en_US: custom_promptja_JP: custom_promptpt_BR: custom_promptzh_Hans: 自定义提示llm_description: custom_promptmax: nullmin: nullname: custom_promptoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: formhuman_description:en_US: with_commentja_JP: with_commentpt_BR: with_commentzh_Hans: 是否包含注释label:en_US: with_commentja_JP: with_commentpt_BR: with_commentzh_Hans: 是否包含注释llm_description: with_commentmax: nullmin: nullname: with_commentoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: booleanparams: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_text2dataprovider_name: jaguarliuu/rookie_text2data/rookie_text2dataprovider_type: builtinselected: falsetitle: rookie_text2datatool_configurations:db_name: ssmdb_type: mysqlhost: 192.168.0.107limit: nullmodel:completion_params: {}mode: chatmodel: qwen2.5vl:7bmodel_type: llmprovider: langgenius/ollama/ollamatype: model-selectorpassword: jiang1987port: 3306result_format: textusername: ssmwith_comment: 1tool_description: 使用自然语言从MySQL获取数据tool_label: rookie_text2datatool_name: rookie_text2datatool_parameters:custom_prompt:type: mixedvalue: '绿色指标表表注释表名称: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: mixedvalue: '{{#llm.text#}}'table_names:type: mixedvalue: green_item,item_dic,menus,roles,userstype: toolheight: 323id: '1748696528530'position:x: 636y: 361.5positionAbsolute:x: 636y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:desc: ''is_team_authorization: trueoutput_schema: nullparamSchemas:- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database typeja_JP: Database typept_BR: Database typezh_Hans: 数据库类型label:en_US: Database typeja_JP: Database typept_BR: Database typezh_Hans: 数据库类型llm_description: Database typemax: nullmin: nullname: db_typeoptions:- label:en_US: MySQLja_JP: MySQLpt_BR: MySQLzh_Hans: MySQLvalue: mysql- label:en_US: PostgreSQLja_JP: PostgreSQLpt_BR: PostgreSQLzh_Hans: PostgreSQLvalue: postgresqlplaceholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: select- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database ip/hostja_JP: Database ip/hostpt_BR: Database ip/hostzh_Hans: 数据库IP/域名label:en_US: Database ip/hostja_JP: Database ip/hostpt_BR: Database ip/hostzh_Hans: 数据库IP/域名llm_description: Database ip/hostmax: nullmin: nullname: hostoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database portja_JP: Database portpt_BR: Database portzh_Hans: 数据库端口label:en_US: Database portja_JP: Database portpt_BR: Database portzh_Hans: 数据库端口llm_description: Database portmax: 65535min: 1name: portoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: number- auto_generate: nulldefault: nullform: formhuman_description:en_US: Database nameja_JP: Database namept_BR: Database namezh_Hans: 数据库名称label:en_US: Database nameja_JP: Database namept_BR: Database namezh_Hans: 数据库名称llm_description: Database namemax: nullmin: nullname: db_nameoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: formhuman_description:en_US: Usernameja_JP: Usernamept_BR: Usernamezh_Hans: 用户名label:en_US: Usernameja_JP: Usernamept_BR: Usernamezh_Hans: 用户名llm_description: Usernamemax: nullmin: nullname: usernameoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: formhuman_description:en_US: Passwordja_JP: Passwordpt_BR: Passwordzh_Hans: 密码label:en_US: Passwordja_JP: Passwordpt_BR: Passwordzh_Hans: 密码llm_description: Passwordmax: nullmin: nullname: passwordoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: secret-input- auto_generate: nulldefault: nullform: llmhuman_description:en_US: Schema nameja_JP: Schema namept_BR: Schema namezh_Hans: 数据库Schema PGSQL用户选填,默认为publiclabel:en_US: Schema nameja_JP: Schema namept_BR: Schema namezh_Hans: 数据库Schema PGSQL用户选填,默认为publicllm_description: Schema namemax: nullmin: nullname: schemaoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_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 stringja_JP: SQL stringpt_BR: SQL stringzh_Hans: 待执行的 SQL 语句llm_description: Fetching data from the database using natural language.max: nullmin: nullname: sqloptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: jsonform: formhuman_description:en_US: result_formatja_JP: result_formatpt_BR: result_formatzh_Hans: 返回数据格式label:en_US: result_formatja_JP: result_formatpt_BR: result_formatzh_Hans: 返回数据格式llm_description: result_formatmax: nullmin: nullname: result_formatoptions:- label:en_US: JSONja_JP: JSONpt_BR: JSONzh_Hans: JSONvalue: json- label:en_US: TEXTja_JP: TEXTpt_BR: TEXTzh_Hans: TEXTvalue: text- label:en_US: CSVja_JP: CSVpt_BR: CSVzh_Hans: CSVvalue: csvplaceholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: selectparams:db_name: ''db_type: ''host: ''password: ''port: ''result_format: ''schema: ''sql: ''username: ''provider_id: jaguarliuu/rookie_text2data/rookie_text2dataprovider_name: jaguarliuu/rookie_text2data/rookie_text2dataprovider_type: builtinselected: falsetitle: rookie_excute_sqltool_configurations:db_name: ssmdb_type: mysqlhost: 192.168.0.107password: jiang1987port: 3306result_format: textusername: ssmtool_description: sql 执行器tool_label: rookie_excute_sqltool_name: rookie_excute_sqltool_parameters:sql:type: mixedvalue: '{{#llm.text#}}'type: toolheight: 245id: '1748696624432'position:x: 939y: 361.5positionAbsolute:x: 939y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:cases:- case_id: 'true'conditions:- comparison_operator: containsid: 0e10be77-29c5-466c-b950-07548022a669value:varType: stringvariable_selector:- sys- queryid: 'true'logical_operator: and- case_id: 6f64ec9a-f939-412f-b673-2bc1a852d5ceconditions:- comparison_operator: containsid: f52c2ed9-0a5d-4e8f-8bff-01b13742d267value: excelvarType: stringvariable_selector:- sys- query- comparison_operator: containsid: 4b0a8f85-7221-4d02-acf4-f709c707d7fbvalue: ExcelvarType: stringvariable_selector:- sys- query- comparison_operator: containsid: 64c7dc5d-2c3c-4786-8cec-f7db37057475value: EXCELvarType: stringvariable_selector:- sys- queryid: 6f64ec9a-f939-412f-b673-2bc1a852d5celogical_operator: anddesc: ''selected: falsetitle: 条件分支type: if-elseheight: 225id: '1748696664775'position:x: 1242y: 361.5positionAbsolute:x: 1242y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:context:enabled: falsevariable_selector: []desc: ''model:completion_params: {}mode: chatname: qwen2.5vl:7bprovider: langgenius/ollama/ollamaprompt_template:- id: 7f02bbf8-3196-4a90-9405-482a585afcc8role: systemtext: '#任务根据用户需求,以及数据内容,自行判断哪种图表类型适合#输出只输入你推荐的图表类型名称,从以下类型中选择一个输出:柱状图、折线图、饼图,散点图,矩形树图'- id: 5c0fe9be-9e09-4679-b247-aeab12cdc8bbrole: usertext: '用户问题:{{#sys.query#}}数据库数据:{{#1748696528530.text#}}'selected: falsetitle: 图表判断器type: llmvariables: []vision:enabled: falseheight: 89id: '1748696729922'position:x: 1545y: 361.5positionAbsolute:x: 1545y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:context:enabled: falsevariable_selector: []desc: ''model:completion_params: {}mode: chatname: qwen2.5vl:7bprovider: langgenius/ollama/ollamaprompt_template:- id: 802dc976-d7c7-4222-b8a8-2ca473820037role: systemtext: '#任务请将用户提供的文档内容转化为标准的json内容,不包含“josn”的标签,只输出标准josn'- id: 67ebe4d2-123c-499c-8d8b-dc20c34f7600role: usertext: 用户提供的文档内容:{{#1748696624432.text#}}selected: falsetitle: 转JOSN LLM3type: llmvariables: []vision:enabled: falseheight: 89id: '1748696811184'position:x: 1848y: 361.5positionAbsolute:x: 1848y: 361.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:desc: ''is_team_authorization: trueoutput_schema: nullparamSchemas:- auto_generate: nulldefault: nullform: formhuman_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: Modelja_JP: Modelpt_BR: Modelzh_Hans: 模型llm_description: LLM model for text2data.max: nullmin: nullname: modeloptions: []placeholder: nullprecision: nullrequired: truescope: llmtemplate: nulltype: model-selector- auto_generate: nulldefault: nullform: llmhuman_description:en_US: wait for dataja_JP: wait for datapt_BR: wait for datazh_Hans: 待处理的数据,建议为json格式或mdlabel:en_US: dataja_JP: datapt_BR: datazh_Hans: 待处理的数据,建议为json格式或mdllm_description: wait for datamax: nullmin: nullname: dataoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_description:en_US: titleja_JP: titlept_BR: titlezh_Hans: 图表标题,不填则大模型推理生成label:en_US: titleja_JP: titlept_BR: titlezh_Hans: 图表标题,不填则大模型推理生成llm_description: titlemax: nullmin: nullname: titleoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_description:en_US: chart typeja_JP: chart typept_BR: chart typezh_Hans: 图表类型label:en_US: chart typeja_JP: chart typept_BR: chart typezh_Hans: 图表类型llm_description: chart typemax: nullmin: nullname: chart_typeoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_description:en_US: custom requirementsja_JP: custom requirementspt_BR: custom requirementszh_Hans: 自定义需求label:en_US: custom requirementsja_JP: custom requirementspt_BR: custom requirementszh_Hans: 自定义需求llm_description: custom requirementsmax: nullmin: nullname: custom_requirementsoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: stringparams:chart_type: ''custom_requirements: ''data: ''model: ''title: ''provider_id: jaguarliuu/rookie_data_alchemy/rookie_data_alchemyprovider_name: jaguarliuu/rookie_data_alchemy/rookie_data_alchemyprovider_type: builtinselected: falsetitle: rookie_data_alchemytool_configurations:model:completion_params: {}mode: chatmodel: deepseek-r1:7bmodel_type: llmprovider: langgenius/ollama/ollamatype: model-selectortool_description: Visualizing structured data as chartstool_label: rookie_data_alchemytool_name: rookie_data_alchemytool_parameters:chart_type:type: mixedvalue: '{{#1748696729922.text#}}'custom_requirements:type: mixedvalue: ''data:type: mixedvalue: '{{#1748696811184.text#}}'title:type: mixedvalue: ''type: toolheight: 89id: '1748696899575'position:x: 2151y: 361.5positionAbsolute:x: 2151y: 361.5selected: truesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:context:enabled: falsevariable_selector: []desc: ''model:completion_params: {}mode: chatname: qwen2.5vl:7bprovider: langgenius/ollama/ollamaprompt_template:- id: 2d5be626-1a76-4d04-bc8c-2f57cae3fe96role: systemtext: '#任务把数据库数据转化为表格类型的markdown文本内容,并把表头翻译为中文#输出只输出转化后的表格类型的markdown,不是要“''“markdown\n”''”等语言标签,只输出标准的markdown表格'- id: 9d64935a-8b00-4d2c-ad97-f6a46a113a36role: usertext: ''selected: falsetitle: 转markdown格式type: llmvariables: []vision:enabled: falseheight: 89id: '1748697147705'position:x: 1545y: 498positionAbsolute:x: 1545y: 498selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:desc: ''is_team_authorization: trueoutput_schema: nullparamSchemas:- auto_generate: nulldefault: nullform: llmhuman_description:en_US: Markdown table textja_JP: Markdown table textpt_BR: Markdown table textzh_Hans: Markdown格式文本,必须为Markdown表格格式,可包含多个表格label:en_US: Markdown textja_JP: Markdown textpt_BR: Markdown textzh_Hans: Markdown格式文本llm_description: ''max: nullmin: nullname: md_textoptions: []placeholder: nullprecision: nullrequired: truescope: nulltemplate: nulltype: string- auto_generate: nulldefault: nullform: llmhuman_description:en_US: Filename of the output fileja_JP: Filename of the output filept_BR: Filename of the output filezh_Hans: 输出文件名label:en_US: Filename of the output fileja_JP: Filename of the output filept_BR: Filename of the output filezh_Hans: 输出文件名llm_description: ''max: nullmin: nullname: output_filenameoptions: []placeholder: nullprecision: nullrequired: falsescope: nulltemplate: nulltype: stringparams:md_text: ''output_filename: ''provider_id: bowenliang123/md_exporter/md_exporterprovider_name: bowenliang123/md_exporter/md_exporterprovider_type: builtinselected: falsetitle: Markdown转XLSX文件tool_configurations: {}tool_description: 一个用于将Markdown转换为XLSX文件的工具tool_label: Markdown转XLSX文件tool_name: md_to_xlsxtool_parameters:md_text:type: mixedvalue: '{{#1748697147705.text#}}'output_filename:type: mixedvalue: ''type: toolheight: 53id: '1748697966459'position:x: 1848y: 516positionAbsolute:x: 1848y: 516sourcePosition: righttargetPosition: lefttype: customwidth: 243- data:answer: '{{#sys.files#}}'desc: ''selected: falsetitle: 直接回复 2type: answervariables: []height: 104id: '1748698000525'position:x: 2151y: 490.5positionAbsolute:x: 2151y: 490.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:context:enabled: falsevariable_selector: []desc: ''model:completion_params: {}mode: chatname: qwen2.5vl:7bprovider: langgenius/ollama/ollamaprompt_template:- id: d05a33f6-5888-41db-8533-fbe04d312a19role: systemtext: '#角色你是一个精通数据处理、分析和总结的大师#任务你可以根据用户的问题,从提供的数据库中检索相关信息,整合提炼后用精准合适的自然语言来回复用户#输出1.若用户只是查询数据,则提炼之后直接回复数据即可2.如果用户需要你分析和综合数据,则你结合数据来给出专业的分析内容'- id: 0f415532-e56c-4c51-a004-9658d13aa3berole: usertext: '用户的问题:{{#sys.query#}}数据库数据:{{#1748696624432.text#}}'selected: falsetitle: LLM 5type: llmvariables: []vision:enabled: falseheight: 89id: '1748698025100'position:x: 1545y: 627positionAbsolute:x: 1545y: 627selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243- data:answer: '{{#1748698025100.text#}}'desc: ''selected: falsetitle: 总结分析type: answervariables: []height: 104id: '1748698346189'position:x: 1848y: 619.5positionAbsolute:x: 1848y: 619.5selected: falsesourcePosition: righttargetPosition: lefttype: customwidth: 243viewport:x: -964.6500000000001y: -95.05000000000001zoom: 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 待研究

相关文章:

  • python打卡day42
  • Mask_RCNN 环境配置及训练
  • leetcode hot100 二叉树(一)
  • 第七部分:第四节 - 在 NestJS 应用中集成 MySQL (使用 TypeORM):结构化厨房的原材料管理系统
  • 剑指offer hot100 第三周
  • 查看make命令执行后涉及的预编译宏定义的值
  • java synchronized关键字用法
  • io流2——字节输入流,文件拷贝
  • Codeforces 1027 Div3(ABCDEF)
  • Java网络编程基础:从阻塞式I/O到线程池模型
  • DAY 34 超大力王爱学Python
  • C++ —— STL容器——string类
  • ps中通过拷贝的图层和通过剪切的图层
  • java多线程与JUC
  • ck-editor5的研究 (4):初步使用 CKEditor5 的插件功能
  • Cesium快速入门到精通系列教程三
  • 高速串行接口
  • Spring Boot 4.0实战:构建高并发电商系统
  • ArkTS基础
  • spining-lidar的电机和激光雷达体(lidar-imu)之间的标定
  • 网站开发与应用 大作业作业/高级seo是什么职位
  • 宜昌市网站建设公司/企业网站建设方案
  • 中国菲律宾热身赛/福鼎网站优化公司
  • 纪委网站微信建设/天津百度网站排名优化
  • 山东大学青岛校区建设指挥部网站/软文推广名词解释
  • 个人网站制作论文/网站优化分析