Dify Dsl Generator
专业的 Dify 工作流 DSL/YML 文件生成器,根据用户业务需求自动生成完整的 Dify 工作流配置文件,支持各种节点类型和复杂工作流逻辑
Specification
- Skill ID
- wwwzhouhui/skills_collection/dify-dsl-generator
- Publisher
- wwwzhouhui
- Repository
- skills_collection
- Installs
- 0
- Files
- 6
- Synced
- Sep 23, 2026
How to use it
Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.
wwwzhouhui/skills_collection/dify-dsl-generatorInstalls these files- .gitignore
- README.md
- SKILL.md
- examples/example-agent-workflow.yml
- examples/example-ocr-workflow.yml
- references/dsl-structure.md
What this skill tells the agent
Dify DSL 工作流生成器
专业的 Dify 工作流 DSL/YML 文件自动生成工具,基于对 86+ 实际工作流案例的深度学习,能够根据用户的业务需求自动生成符合 Dify 规范的完整工作流配置文件。
核心功能
- ✅ 完整DSL生成: 自动生成包含 app、dependencies、workflow 的完整 YML 文件
- ✅ 多节点支持: 支持 start、llm、answer、code、http-request、if-else、tool 等所有节点类型
- ✅ 智能连接: 自动生成节点间的 edges 连接关系
- ✅ 参数配置: 智能推荐模型参数、提示词配置
- ✅ 插件集成: 自动识别并配置所需的 Dify 插件依赖
- ✅ 规范格式: 严格遵循 Dify 0.3.0 版本的 DSL 规范
使用方法
基础用法
生成一个 Dify 工作流用于 [业务需求描述]详细用法
帮我生成一个 Dify 工作流 DSL 文件:
- 功能: [工作流要实现的功能]
- 输入: [用户输入的内容]
- 处理步骤: [详细的处理逻辑]
- 输出: [期望的输出结果]
- 使用插件: [需要的插件,可选]Dify DSL 文件结构
基于对 86+ 真实工作流案例的学习,Dify DSL YML 文件遵循以下结构:
1. App 配置
app:
description: '工作流描述'
icon: 🤖
icon_background: '#FFEAD5'
mode: advanced-chat # 或 workflow, agent-chat
name: 工作流名称
use_icon_as_answer_icon: false模式说明:
advanced-chat: 高级对话模式(chatflow)workflow: 工作流模式agent-chat: AI Agent 模式
2. Dependencies 依赖
dependencies:
- current_identifier: null
type: marketplace
value:
marketplace_plugin_unique_identifier: 插件唯一标识符常用插件:
langgenius/openai_api_compatible: OpenAI 兼容接口bowenliang123/md_exporter: Markdown 导出器- 其他市场插件根据需求添加
3. Workflow 工作流
kind: app
version: 0.3.0
workflow:
conversation_variables: []
environment_variables: []
features:
file_upload:
enabled: false
speech_to_text:
enabled: false
text_to_speech:
enabled: false
graph:
edges: []
nodes: []节点类型详解
Start 开始节点
- data:
desc: ''
title: 开始
type: start
variables:
- label: 用户输入
max_length: 1000
options: []
required: true
type: paragraph # 或 text-input, select, file
variable: query
id: 'start'
position:
x: 100
y: 300
type: custom
width: 244
height: 90变量类型:
paragraph: 段落文本(多行)text-input: 单行文本select: 下拉选择file: 文件上传number: 数字
LLM 大语言模型节点
- data:
context:
enabled: false
variable_selector: []
model:
completion_params:
temperature: 0.7
max_tokens: 2000
mode: chat
name: gpt-4
provider: openai
prompt_template:
- id: 唯一ID
role: system
text: 系统提示词
- id: 唯一ID
role: user
text: 用户提示词 {{#变量引用#}}
title: LLM节点
type: llm
vision:
enabled: false
id: '节点ID'
position:
x: 400
y: 300
type: custom常用模型provider:
openai: OpenAIlanggenius/openai_api_compatible/openai_api_compatible: 兼容接口anthropic: Claudealibaba: 通义千问
变量引用格式:
{{#节点ID.输出变量#}}: 引用其他节点的输出{{#sys.query#}}: 引用系统变量(用户输入){{#节点ID.text#}}: 引用LLM输出文本
Code 代码执行节点
- data:
code: |
import json
def main(arg1: str, arg2: str) -> dict:
# 处理逻辑
result = process(arg1, arg2)
return {
"result": result,
"status": "success"
}
code_language: python3
outputs:
result:
type: string
status:
type: string
title: 代码执行
type: code
variables:
- value_selector:
- '前置节点ID'
- 输出变量
variable: arg1
id: '节点ID'
position:
x: 700
y: 300
type: custom代码语言:
python3: Python 3javascript: JavaScript (部分版本支持)
输出类型:
string: 字符串number: 数字object: 对象array[string]: 字符串数组array[number]: 数字数组array[object]: 对象数组
HTTP Request 节点
- data:
authorization:
config: null
type: no-auth
body:
data: '{"key": "{{#变量#}}"}'
type: json
headers: ''
method: post
timeout:
max_connect_timeout: 0
max_read_timeout: 0
max_write_timeout: 0
title: HTTP请求
type: http-request
url: https://api.example.com/endpoint
id: '节点ID'
position:
x: 1000
y: 300
type: customHTTP方法:
get: GET 请求post: POST 请求put: PUT 请求patch: PATCH 请求delete: DELETE 请求
认证类型:
no-auth: 无认证api-key: API Keybearer: Bearer Token
If-Else 条件判断节点
- data:
cases:
- case_id: case1
conditions:
- comparison_operator: contains
id: 条件ID
value: 期望值
variable_selector:
- '节点ID'
- 变量名
id: case1
logical_operator: and
logical_operator: or
title: 条件判断
type: if-else
id: '节点ID'
position:
x: 1300
y: 300
type: custom比较运算符:
contains: 包含not contains: 不包含is: 等于is not: 不等于empty: 为空not empty: 不为空
逻辑运算符:
and: 与or: 或
Tool 工具节点
- data:
provider_id: 工具提供者ID
provider_name: 工具提供者名称
provider_type: builtin # 或 api
title: 工具调用
tool_configurations: {}
tool_label: 工具标签
tool_name: 工具名称
tool_parameters:
参数名:
type: mixed
value: '{{#变量#}}'
type: tool
id: '节点ID'
position:
x: 1600
y: 300
type: custom工具类型:
builtin: 内置工具(如搜索、天气等)api: API 工具plugin: 插件工具
Answer 直接回复节点
- data:
answer: |
{{#LLM节点ID.text#}}
{{#代码节点ID.result#}}
title: 直接回复
type: answer
variables: []
id: answer
position:
x: 1900
y: 300
type: customVariable Aggregator 变量聚合器节点
- data:
advanced_settings: null
desc: ''
groups:
- group_name: 分组1
output_type: string
variables:
- value_selector:
- '节点ID'
- 变量名
variable: 输出变量名
title: 变量聚合器
type: variable-aggregator
id: '节点ID'
position:
x: 2200
y: 300
type: customParameter Extractor 参数提取器节点
- data:
instruction: 提取指令说明
is_array: false
model:
completion_params: {}
mode: chat
name: gpt-4
provider: openai
parameters:
- description: 参数描述
name: 参数名
required: true
type: string
query:
- role: user
text: '{{#输入变量#}}'
reasoning_mode: prompt
title: 参数提取
type: parameter-extractor
id: '节点ID'
position:
x: 2500
y: 300
type: customEdges 连接关系
edges:
- data:
isInIteration: false
isInLoop: false
sourceType: start
targetType: llm
id: 源节点ID-source-目标节点ID-target
source: '源节点ID'
sourceHandle: source
target: '目标节点ID'
targetHandle: target
type: custom
zIndex: 0连接规则:
- 每个节点至多有一个入边(start 节点除外)
- 节点可以有多个出边(if-else 等分支节点)
- 最终必须连接到 answer 节点或其他输出节点
sourceType和targetType必须与实际节点类型匹配
Position 坐标布局
推荐布局:
- 起始 X: 100
- 节点间距 X: 300-400
- Y 坐标: 保持在同一水平线(300)或根据分支适当调整
- 分支节点的子节点 Y 坐标: ±150
示例布局:
Start(100,300) → LLM(400,300) → Code(700,300) → Answer(1000,300)分支布局:
→ Branch1(1100,150)
If-Else(800,300) →
→ Branch2(1100,450)生成工作流步骤
1. 需求分析
- 理解用户的业务需求
- 确定工作流类型(chatflow/workflow/agent)
- 识别所需的节点类型
- 规划处理流程
2. 节点设计
- 设计开始节点的输入变量
- 规划 LLM 节点的提示词
- 确定代码执行逻辑
- 配置 HTTP 请求参数
- 设计输出格式
3. 流程连接
- 建立节点间的逻辑关系
- 配置变量传递
- 处理条件分支
- 确保流程闭环
4. DSL 生成
- 生成符合规范的 YAML 格式
- 配置唯一的节点 ID
- 设置合理的坐标位置
- 添加必要的依赖插件
5. 验证检查
- 检查 YAML 格式正确性
- 验证变量引用完整性
- 确认节点连接合理性
- 检查必填字段完整性
实际案例学习
基于 86+ 真实工作流案例的学习总结:
案例1: 图片 OCR 识别工作流
需求: 上传图片 → OCR 识别 → 提取文字
节点流程:
- Start(file input) →
- LLM(vision enabled, OCR) →
- Answer(display result)
关键配置:
- Start 节点: type: file, allowed_file_types: [image]
- LLM 节点: vision.enabled: true, vision.configs.variable_selector 指向文件变量
- 系统提示词: "仅输出识别到的图片中的文字信息"
案例2: 文本生成 HTML 工作流
需求: 文本描述 → 生成HTML代码 → 保存为文件
节点流程:
- Start(text input) →
- LLM(generate HTML) →
- Parameter Extractor(extract HTML code) →
- Tool(md_exporter, save file) →
- Answer(return file URL)
关键配置:
- LLM 提示词: "生成 HTML 程序,仅输出 HTML 代码"
- Parameter Extractor: 提取 HTML 代码块
- Tool: 使用 md_exporter 插件保存文件
案例3: 数据查询可视化工作流
需求: 用户问题 → SQL 查询 → 图表展示
节点流程:
- Start(query input) →
- LLM(generate SQL) →
- HTTP Request(database API) →
More from wwwzhouhui
Use this skill in a project
Open any RiverX project, search the Skills panel for wwwzhouhui/skills_collection/dify-dsl-generator, and install it in one click.
