fastgpt-workflow-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFastGPT Workflow Generator
FastGPT工作流生成器
Automatically generate production-ready FastGPT workflow JSON from natural language requirements
根据自然语言需求自动生成可直接用于生产环境的FastGPT工作流JSON
When to Use This Skill
何时使用该技能
Use this skill when you need to:
- Create new workflows from scratch: User asks to "create a FastGPT workflow for X purpose"
- Generate based on templates: User wants to build workflows similar to existing patterns (document processing, AI chat, data analysis, multi-agent systems)
- Modify existing workflows: User needs to add/remove/update nodes in an existing workflow JSON
- Validate workflow JSON: User has a workflow JSON that needs verification or fixing
- Design multi-agent systems: User mentions parallel processing, agent coordination, or workflow orchestration
- Automate workflow creation: User provides requirements document and needs executable JSON
- Convert requirements to JSON: User has specifications and wants a FastGPT-compatible workflow
Trigger Keywords: FastGPT, workflow, JSON, multi-agent, 工作流, template matching, workflow automation, node configuration, workflow validation
在以下场景中使用本技能:
- 从零创建新工作流:用户要求“为X用途创建FastGPT工作流”
- 基于模板生成:用户希望构建与现有模式(文档处理、AI聊天、数据分析、多智能体系统)类似的工作流
- 修改现有工作流:用户需要在现有工作流JSON中添加/删除/更新节点
- 验证工作流JSON:用户有需要验证或修复的工作流JSON
- 设计多智能体系统:用户提及并行处理、智能体协调或工作流编排
- 自动化工作流创建:用户提供需求文档,需要可执行的JSON
- 将需求转换为JSON:用户有规格说明,需要生成兼容FastGPT的工作流
触发关键词:FastGPT, workflow, JSON, multi-agent, 工作流, template matching, workflow automation, node configuration, workflow validation
Core Workflow
核心工作流
This skill follows a 5-phase process to generate production-ready workflow JSON:
本技能遵循5阶段流程生成可用于生产环境的工作流JSON:
Phase 1: Requirements Analysis
阶段1:需求分析
Goal: Extract structured requirements from natural language input
Process:
-
Identify request type:
- Create from scratch
- Based on template
- Modify existing workflow
- Validate/fix existing JSON
-
Extract key information using AI semantic analysis:json
{ "purpose": "Workflow objective (e.g., 'Travel planning assistance')", "domain": "Application domain (travel/event/document/data/general)", "complexity": "simple | medium | complex", "features": ["aiChat", "knowledgeBase", "httpRequest", "parallel"], "inputs": ["userChatInput", "city", "date"], "outputs": ["Complete plan", "Recommendations"], "externalIntegrations": ["Weather API", "Feishu API"], "specialRequirements": ["Multi-agent", "Real-time data"] } -
Completeness check: If information is insufficient, clarify through dialogue
Output: Structured requirements object
目标:从自然语言输入中提取结构化需求
流程:
-
识别请求类型:
- 从零创建
- 基于模板
- 修改现有工作流
- 验证/修复现有JSON
-
使用AI语义分析提取关键信息:json
{ "purpose": "工作流目标(例如:'旅行规划协助')", "domain": "应用领域(旅行/活动/文档/数据/通用)", "complexity": "simple | medium | complex", "features": ["aiChat", "knowledgeBase", "httpRequest", "parallel"], "inputs": ["userChatInput", "city", "date"], "outputs": ["完整规划", "推荐建议"], "externalIntegrations": ["Weather API", "飞书API"], "specialRequirements": ["Multi-agent", "实时数据"] } -
完整性检查:如果信息不足,通过对话澄清
输出:结构化需求对象
Phase 2: Template Matching
阶段2:模板匹配
Goal: Find the most similar built-in template
Built-in Templates (stored in directory):
templates/- - Simple workflow (document processing)
templates/文档翻译助手.json - - Medium complexity (conversational AI)
templates/销售陪练大师.json - - Complex workflow (data processing + external integration)
templates/简历筛选助手_飞书.json - - Scheduled trigger + multi-agent (news aggregation)
templates/AI金融日报.json
Matching Strategy:
Step 1: Coarse Filtering (Metadata-based)
Calculate similarity scores:
- Domain match: travel vs travel = 1.0, travel vs event = 0.3
- Complexity match: simple vs simple = 1.0, simple vs complex = 0.3
- Feature overlap: Jaccard similarity of feature sets
- Node count similarity: 1 - |count1 - count2| / max(count1, count2)
Combined score = 0.3 * domain + 0.2 * complexity + 0.3 * features + 0.2 * nodeCount
Select Top 3 candidate templatesStep 2: Fine Filtering (Semantic Similarity)
For Top 3 candidates:
1. Analyze user requirements vs template characteristics
2. Evaluate workflow structure similarity
3. Calculate comprehensive score
Final score = 0.3 * domain + 0.2 * complexity + 0.3 * features + 0.2 * semanticStep 3: Selection Strategy
- Highest score < 0.5: Start from blank template
- Highest score 0.5-0.7: Use template as reference, major modifications
- Highest score > 0.7: Use template as base, minor adjustmentsOutput:
- Best matching template JSON object
- Matching analysis report
- Modification suggestions list
目标:找到最相似的内置模板
内置模板(存储在目录中):
templates/- - 简单工作流(文档处理)
templates/文档翻译助手.json - - 中等复杂度(对话式AI)
templates/销售陪练大师.json - - 复杂工作流(数据处理+外部集成)
templates/简历筛选助手_飞书.json - - 定时触发+多智能体(新闻聚合)
templates/AI金融日报.json
匹配策略:
步骤1:粗过滤(基于元数据)
计算相似度得分:
- 领域匹配:旅行vs旅行=1.0,旅行vs活动=0.3
- 复杂度匹配:简单vs简单=1.0,简单vs复杂=0.3
- 功能重叠:功能集合的杰卡德相似度
- 节点数量相似度:1 - |count1 - count2| / max(count1, count2)
综合得分 = 0.3*领域 + 0.2*复杂度 + 0.3*功能 + 0.2*节点数量
选择前3个候选模板步骤2:细过滤(语义相似度)
对于前3个候选模板:
1. 分析用户需求与模板特征
2. 评估工作流结构相似度
3. 计算综合得分
最终得分 = 0.3*领域 + 0.2*复杂度 + 0.3*功能 + 0.2*语义步骤3:选择策略
- 最高得分 < 0.5:从空白模板开始
- 最高得分 0.5-0.7:以模板为参考,进行重大修改
- 最高得分 > 0.7:以模板为基础,进行小幅调整输出:
- 最佳匹配模板JSON对象
- 匹配分析报告
- 修改建议列表
Phase 3: JSON Generation
阶段3:JSON生成
Scenario 1: Generate Based on Template
1. Copy template structure
2. Modify nodes
- Keep: structurally similar nodes (workflowStart, userGuide)
- Modify: nodes requiring prompt/parameter adjustments
- Delete: unnecessary nodes
- Add: new requirement nodes
3. Regenerate NodeId
function generateNodeId(nodeType, nodeName, existingIds) {
// Fixed ID mapping
if (nodeType === 'workflowStart') return 'workflowStart';
if (nodeType === 'userGuide' || nodeType === 'systemConfig') return 'userGuide';
// Generate semantic ID (camelCase)
const baseName = nodeName.replace(/[\s\u4e00-\u9fa5]+/g, '');
let nodeId = baseName ? `${baseName}Node` : `${nodeType}Node`;
// Ensure uniqueness
let counter = 1;
while (existingIds.has(nodeId)) {
nodeId = `${baseName}Node_${counter}`;
counter++;
}
return nodeId;
}
4. Update references
- Traverse all inputs, replace old nodeId with new nodeId
- Update edges' source/target
- Handle two reference formats:
- Array: ["nodeId", "key"]
- Template: {{$nodeId.key$}} (Note: double braces with single $)
5. Auto-layout positions (hierarchical layout algorithm)
function autoLayout(nodes, edges) {
// Topological sort to determine layers
const layers = topologicalLayering(nodes, edges);
// Calculate positions for each layer
const LAYER_GAP_X = 350;
const NODE_GAP_Y = 150;
layers.forEach((layer, layerIndex) => {
const x = -200 + layerIndex * LAYER_GAP_X;
const totalHeight = (layer.length - 1) * NODE_GAP_Y;
const startY = -totalHeight / 2;
layer.forEach((nodeId, nodeIndex) => {
positions[nodeId] = {
x: x,
y: startY + nodeIndex * NODE_GAP_Y
};
});
});
// Fixed position for special nodes
positions['userGuide'] = { x: -600, y: -250 };
}
6. Update configuration
- Modify chatConfig.welcomeText
- Update chatConfig.variablesScenario 2: Create from Scratch
1. Determine node list
- Required: workflowStart, userGuide
- Add based on features: chatNode, datasetSearchNode, httpRequest468, etc.
- Required: answerNode (output node)
2. Generate nodes and connections
- Use standard node templates
- Fill required fields
- Customize inputs/outputs based on requirements
3. Calculate positions and generate configurationOutput: Complete FastGPT workflow JSON
场景1:基于模板生成
1. 复制模板结构
2. 修改节点
- 保留:结构相似的节点(workflowStart, userGuide)
- 修改:需要调整提示词/参数的节点
- 删除:不必要的节点
- 添加:满足新需求的节点
3. 重新生成NodeId
function generateNodeId(nodeType, nodeName, existingIds) {
// 固定ID映射
if (nodeType === 'workflowStart') return 'workflowStart';
if (nodeType === 'userGuide' || nodeType === 'systemConfig') return 'userGuide';
// 生成语义化ID(驼峰式)
const baseName = nodeName.replace(/[\s\u4e00-\u9fa5]+/g, '');
let nodeId = baseName ? `${baseName}Node` : `${nodeType}Node`;
// 确保唯一性
let counter = 1;
while (existingIds.has(nodeId)) {
nodeId = `${baseName}Node_${counter}`;
counter++;
}
return nodeId;
}
4. 更新引用
- 遍历所有输入,将旧nodeId替换为新nodeId
- 更新edges的source/target
- 处理两种引用格式:
- 数组格式:["nodeId", "key"]
- 模板格式:{{$nodeId.key$}} (注意:双大括号加单个$)
5. 自动布局位置(分层布局算法)
function autoLayout(nodes, edges) {
// 拓扑排序确定层级
const layers = topologicalLayering(nodes, edges);
// 计算每个层级的位置
const LAYER_GAP_X = 350;
const NODE_GAP_Y = 150;
layers.forEach((layer, layerIndex) => {
const x = -200 + layerIndex * LAYER_GAP_X;
const totalHeight = (layer.length - 1) * NODE_GAP_Y;
const startY = -totalHeight / 2;
layer.forEach((nodeId, nodeIndex) => {
positions[nodeId] = {
x: x,
y: startY + nodeIndex * NODE_GAP_Y
};
});
});
// 特殊节点的固定位置
positions['userGuide'] = { x: -600, y: -250 };
}
6. 更新配置
- 修改chatConfig.welcomeText
- 更新chatConfig.variables场景2:从零创建
1. 确定节点列表
- 必填:workflowStart, userGuide
- 根据功能添加:chatNode, datasetSearchNode, httpRequest468等
- 必填:answerNode(输出节点)
2. 生成节点和连接
- 使用标准节点模板
- 填充必填字段
- 根据需求自定义输入/输出
3. 计算位置并生成配置输出:完整的FastGPT工作流JSON
Phase 4: Validation
阶段4:验证
Level 1: JSON Format Validation
✅ JSON is parseable
✅ Top level contains nodes, edges, chatConfig
✅ Each node contains: nodeId, name, flowNodeType, position, inputs, outputs
✅ flowNodeType is in valid type list (40+ types)
✅ position contains x, y numeric coordinatesLevel 2: Node Connection Validation
✅ edges' source/target nodes exist
✅ sourceHandle/targetHandle format correct (nodeId-source-right, nodeId-target-left)
✅ Node input references' nodes and output keys exist
✅ Reference types match (string → string)
✅ Template references {{$nodeId.key$}} nodes and keys exist
✅ No self-loops, no duplicate connectionsLevel 3: Logic Completeness Validation
✅ Required nodes exist (workflowStart, userGuide, at least one output node)
✅ All nodes reachable from workflowStart (connectivity)
✅ No illegal cycles (unless using loop node)
✅ loop nodes correctly configured with parentNodeId and childrenNodeIdList
✅ No dead ends (non-output nodes without outgoing edges)
✅ All required inputs have valuesOutput: Validation report (containing errors, warnings, fix suggestions)
第一层:JSON格式验证
✅ JSON可解析
✅ 顶层包含nodes, edges, chatConfig
✅ 每个节点包含:nodeId, name, flowNodeType, position, inputs, outputs
✅ flowNodeType属于有效类型列表(40+种)
✅ position包含x, y数值坐标第二层:节点连接验证
✅ edges的source/target节点存在
✅ sourceHandle/targetHandle格式正确(nodeId-source-right, nodeId-target-left)
✅ 节点输入引用的节点和输出键存在
✅ 引用类型匹配(字符串→字符串)
✅ 模板引用{{$nodeId.key$}}的节点和键存在
✅ 无自环,无重复连接第三层:逻辑完整性验证
✅ 必填节点存在(workflowStart, userGuide, 至少一个输出节点)
✅ 所有节点可从workflowStart到达(连通性)
✅ 无非法循环(除非使用loop节点)
✅ loop节点正确配置parentNodeId和childrenNodeIdList
✅ 无死胡同(非输出节点没有出边)
✅ 所有必填输入都有值输出:验证报告(包含错误、警告、修复建议)
Phase 5: Incremental Modification (Optional)
阶段5:增量修改(可选)
Use Cases: Add/delete/modify nodes
Processing Steps:
1. Understand modification intent
Use AI to analyze user request, extract:
{
"action": "add" | "delete" | "modify" | "reconnect",
"targetNodes": ["aiChatNode"],
"insertBefore": "aiChatNode",
"newNodes": [{ "type": "datasetSearchNode", "name": "Knowledge Base Search" }],
"modifications": {
"aiChatNode": {
"inputs": { "quoteQA": ["knowledgeBaseSearch", "searchResult"] }
}
}
}2. Execute modifications
- Add node: generate new node, reconnect, calculate position
- Delete node: remove node, bypass reconnect, clean references
- Modify node: update inputs/outputs, validate references3. Re-layout and validate
使用场景:添加/删除/修改节点
处理步骤:
1. 理解修改意图
使用AI分析用户请求,提取:
{
"action": "add" | "delete" | "modify" | "reconnect",
"targetNodes": ["aiChatNode"],
"insertBefore": "aiChatNode",
"newNodes": [{ "type": "datasetSearchNode", "name": "知识库搜索" }],
"modifications": {
"aiChatNode": {
"inputs": { "quoteQA": ["knowledgeBaseSearch", "searchResult"] }
}
}
}2. 执行修改
- 添加节点:生成新节点,重新连接,计算位置
- 删除节点:移除节点,绕过连接,清理引用
- 修改节点:更新输入/输出,验证引用3. 重新布局并验证
Examples
示例
Example 1: Simple AI Q&A Workflow
示例1:简单AI问答工作流
User Request:
"Create a simple AI Q&A workflow where users input questions and AI responds directly"Skill Processing:
-
Requirements Analysisjson
{ "purpose": "AI question answering", "domain": "general", "complexity": "simple", "features": ["aiChat"], "inputs": ["userChatInput"], "outputs": ["AI response"] } -
Template Matching
- - Score: 0.85 (simple workflow, direct processing)
文档翻译助手.json
-
JSON Generation
- Use template, modify systemPrompt and welcomeText
-
Validation Result
- ✅ All three layers pass validation
Generated JSON (key parts):
json
{
"nodes": [
{
"nodeId": "userGuide",
"name": "System Configuration",
"flowNodeType": "userGuide",
"position": {"x": -600, "y": -250}
},
{
"nodeId": "workflowStart",
"name": "Start",
"flowNodeType": "workflowStart",
"position": {"x": -150, "y": 100},
"outputs": [
{"key": "userChatInput", "type": "static", "valueType": "string"}
]
},
{
"nodeId": "aiChatNode",
"name": "AI Response",
"flowNodeType": "chatNode",
"position": {"x": 200, "y": 100},
"inputs": [
{
"key": "model",
"valueType": "string",
"value": "gpt-4"
},
{
"key": "systemPrompt",
"valueType": "string",
"value": "You are a professional AI assistant that can answer various questions. Please provide accurate and helpful answers based on user questions."
},
{
"key": "userChatInput",
"valueType": "string",
"value": ["workflowStart", "userChatInput"]
}
],
"outputs": [
{"key": "answerText", "type": "static", "valueType": "string"}
]
},
{
"nodeId": "outputNode",
"name": "Output Answer",
"flowNodeType": "answerNode",
"position": {"x": 550, "y": 100},
"inputs": [
{
"key": "text",
"valueType": "string",
"value": ["aiChatNode", "answerText"]
}
]
}
],
"edges": [
{
"source": "workflowStart",
"target": "aiChatNode",
"sourceHandle": "workflowStart-source-right",
"targetHandle": "aiChatNode-target-left"
},
{
"source": "aiChatNode",
"target": "outputNode",
"sourceHandle": "aiChatNode-source-right",
"targetHandle": "outputNode-target-left"
}
],
"chatConfig": {
"welcomeText": "Welcome to the AI Q&A assistant! Please enter your question.",
"variables": []
}
}用户请求:
"创建一个简单的AI问答工作流,用户输入问题后AI直接回复"技能处理:
-
需求分析json
{ "purpose": "AI问答", "domain": "general", "complexity": "simple", "features": ["aiChat"], "inputs": ["userChatInput"], "outputs": ["AI回复"] } -
模板匹配
- - 得分:0.85(简单工作流,直接处理)
文档翻译助手.json
-
JSON生成
- 使用模板,修改systemPrompt和welcomeText
-
验证结果
- ✅ 三层验证全部通过
生成的JSON(关键部分):
json
{
"nodes": [
{
"nodeId": "userGuide",
"name": "系统配置",
"flowNodeType": "userGuide",
"position": {"x": -600, "y": -250}
},
{
"nodeId": "workflowStart",
"name": "开始",
"flowNodeType": "workflowStart",
"position": {"x": -150, "y": 100},
"outputs": [
{"key": "userChatInput", "type": "static", "valueType": "string"}
]
},
{
"nodeId": "aiChatNode",
"name": "AI回复",
"flowNodeType": "chatNode",
"position": {"x": 200, "y": 100},
"inputs": [
{
"key": "model",
"valueType": "string",
"value": "gpt-4"
},
{
"key": "systemPrompt",
"valueType": "string",
"value": "你是专业的AI助手,可以回答各类问题。请根据用户问题提供准确且有帮助的答案。"
},
{
"key": "userChatInput",
"valueType": "string",
"value": ["workflowStart", "userChatInput"]
}
],
"outputs": [
{"key": "answerText", "type": "static", "valueType": "string"}
]
},
{
"nodeId": "outputNode",
"name": "输出答案",
"flowNodeType": "answerNode",
"position": {"x": 550, "y": 100},
"inputs": [
{
"key": "text",
"valueType": "string",
"value": ["aiChatNode", "answerText"]
}
]
}
],
"edges": [
{
"source": "workflowStart",
"target": "aiChatNode",
"sourceHandle": "workflowStart-source-right",
"targetHandle": "aiChatNode-target-left"
},
{
"source": "aiChatNode",
"target": "outputNode",
"sourceHandle": "aiChatNode-source-right",
"targetHandle": "outputNode-target-left"
}
],
"chatConfig": {
"welcomeText": "欢迎使用AI问答助手!请输入你的问题。",
"variables": []
}
}Example 2: Document Translation Workflow (Based on Template)
示例2:文档翻译工作流(基于模板)
User Request:
"Create a document translation workflow that translates user-uploaded documents from Chinese to English"Skill Processing:
-
Requirements Analysisjson
{ "purpose": "Document translation", "domain": "document", "complexity": "medium", "features": ["readFiles", "aiChat", "textOutput"], "inputs": ["userFiles"], "outputs": ["translated document"] } -
Template Matching
- - Score: 0.95 (perfect match!)
文档翻译助手.json
-
JSON Generation
- Use template directly, only adjust language direction in prompt
Generated Workflow Structure:
workflowStart → readFiles → translateNode → outputNodeKey Node Configuration:
- readFiles Node: Reads user-uploaded files
- translateNode (chatNode): AI translates with specialized prompt
- outputNode (answerNode): Outputs translated text
用户请求:
"创建一个文档翻译工作流,将用户上传的文档从中文翻译成英文"技能处理:
-
需求分析json
{ "purpose": "文档翻译", "domain": "document", "complexity": "medium", "features": ["readFiles", "aiChat", "textOutput"], "inputs": ["userFiles"], "outputs": ["翻译后的文档"] } -
模板匹配
- - 得分:0.95(完美匹配!)
文档翻译助手.json
-
JSON生成
- 直接使用模板,仅调整提示词中的语言方向
生成的工作流结构:
workflowStart → readFiles → translateNode → outputNode关键节点配置:
- readFiles节点:读取用户上传的文件
- translateNode(chatNode):AI使用专用提示词进行翻译
- outputNode(answerNode):输出翻译后的文本
Example 3: Incremental Modification (Add Knowledge Base)
示例3:增量修改(添加知识库)
User Request:
"I have an existing AI Q&A workflow (simple_qa_workflow.json),
I want to search the knowledge base first before AI answers,
find relevant information then generate response"Existing Workflow Structure:
workflowStart → aiChatNode → outputNodeModification Goal:
workflowStart → knowledgeBaseSearch → aiChatNode → outputNodeSkill Processing:
-
Analyze Modification Intentjson
{ "action": "add", "targetNodes": ["aiChatNode"], "insertBefore": "aiChatNode", "newNodes": [ { "type": "datasetSearchNode", "name": "Knowledge Base Search" } ], "modifications": { "aiChatNode": { "inputs": { "quoteQA": ["knowledgeBaseSearch", "searchResult"] } } } } -
Execute Modification
- Add node
knowledgeBaseSearch - Modify edge:
workflowStart → knowledgeBaseSearch - Add edge:
knowledgeBaseSearch → aiChatNode - Modify aiChatNode's inputs (add quoteQA)
- Add
-
Re-layout Positions
- workflowStart: (-150, 100)
- knowledgeBaseSearch: (50, 100) ← newly inserted
- aiChatNode: (400, 100) ← shifted right
- outputNode: (750, 100) ← shifted right
-
Validation Result
- ✅ All validations pass
Modified JSON (new and modified parts):
json
{
"nodes": [
{
"nodeId": "knowledgeBaseSearch",
"name": "Knowledge Base Search",
"flowNodeType": "datasetSearchNode",
"position": {"x": 50, "y": 100},
"inputs": [
{
"key": "datasetIds",
"valueType": "selectDataset",
"value": [],
"required": true
},
{
"key": "searchQuery",
"valueType": "string",
"value": ["workflowStart", "userChatInput"],
"required": true
},
{
"key": "similarity",
"valueType": "number",
"value": 0.5
},
{
"key": "limitCount",
"valueType": "number",
"value": 5
}
],
"outputs": [
{
"key": "searchResult",
"type": "static",
"valueType": "datasetQuote"
}
]
},
{
"nodeId": "aiChatNode",
"inputs": [
{
"key": "quoteQA",
"valueType": "datasetQuote",
"value": ["knowledgeBaseSearch", "searchResult"]
}
]
}
],
"edges": [
{
"source": "workflowStart",
"target": "knowledgeBaseSearch"
},
{
"source": "knowledgeBaseSearch",
"target": "aiChatNode"
},
{
"source": "aiChatNode",
"target": "outputNode"
}
]
}Modification Summary Report:
- ✅ Added 1 node: (datasetSearchNode)
knowledgeBaseSearch - ✅ Modified 1 node: (added quoteQA input)
aiChatNode - ✅ Added 1 edge:
knowledgeBaseSearch → aiChatNode - ✅ Modified 1 edge: (originally
workflowStart → knowledgeBaseSearch)workflowStart → aiChatNode - ✅ Re-layouted all positions
用户请求:
"我有一个现有的AI问答工作流(simple_qa_workflow.json),
我希望AI回答前先搜索知识库,
找到相关信息后再生成回复"现有工作流结构:
workflowStart → aiChatNode → outputNode修改目标:
workflowStart → knowledgeBaseSearch → aiChatNode → outputNode技能处理:
-
分析修改意图json
{ "action": "add", "targetNodes": ["aiChatNode"], "insertBefore": "aiChatNode", "newNodes": [ { "type": "datasetSearchNode", "name": "知识库搜索" } ], "modifications": { "aiChatNode": { "inputs": { "quoteQA": ["knowledgeBaseSearch", "searchResult"] } } } } -
执行修改
- 添加节点
knowledgeBaseSearch - 修改边:
workflowStart → knowledgeBaseSearch - 添加边:
knowledgeBaseSearch → aiChatNode - 修改aiChatNode的输入(添加quoteQA)
- 添加
-
重新布局位置
- workflowStart: (-150, 100)
- knowledgeBaseSearch: (50, 100) ← 新插入
- aiChatNode: (400, 100) ← 右移
- outputNode: (750, 100) ← 右移
-
验证结果
- ✅ 所有验证通过
修改后的JSON(新增和修改部分):
json
{
"nodes": [
{
"nodeId": "knowledgeBaseSearch",
"name": "知识库搜索",
"flowNodeType": "datasetSearchNode",
"position": {"x": 50, "y": 100},
"inputs": [
{
"key": "datasetIds",
"valueType": "selectDataset",
"value": [],
"required": true
},
{
"key": "searchQuery",
"valueType": "string",
"value": ["workflowStart", "userChatInput"],
"required": true
},
{
"key": "similarity",
"valueType": "number",
"value": 0.5
},
{
"key": "limitCount",
"valueType": "number",
"value": 5
}
],
"outputs": [
{
"key": "searchResult",
"type": "static",
"valueType": "datasetQuote"
}
]
},
{
"nodeId": "aiChatNode",
"inputs": [
{
"key": "quoteQA",
"valueType": "datasetQuote",
"value": ["knowledgeBaseSearch", "searchResult"]
}
]
}
],
"edges": [
{
"source": "workflowStart",
"target": "knowledgeBaseSearch"
},
{
"source": "knowledgeBaseSearch",
"target": "aiChatNode"
},
{
"source": "aiChatNode",
"target": "outputNode"
}
]
}修改总结报告:
- ✅ 添加1个节点:(datasetSearchNode)
knowledgeBaseSearch - ✅ 修改1个节点:(添加quoteQA输入)
aiChatNode - ✅ 添加1条边:
knowledgeBaseSearch → aiChatNode - ✅ 修改1条边:(原先是
workflowStart → knowledgeBaseSearch)workflowStart → aiChatNode - ✅ 重新布局所有位置
Technical Implementation
技术实现
NodeId Generation Algorithm
NodeId生成算法
Rules:
- Fixed IDs: ,
workflowStart(systemConfig)userGuide - Semantic naming: Generate based on node name (remove spaces and Chinese, convert to camelCase)
- Uniqueness guarantee: If conflict, add ,
_1suffix_2
Examples:
- →
generateNodeId('chatNode', 'Travel Planning Assistant')TravelPlanningAssistantNode - →
generateNodeId('httpRequest468', 'Weather Query')WeatherQueryNode - →
generateNodeId('chatNode', 'Assistant', {TravelPlanningAssistantNode})AssistantNode_1
规则:
- 固定ID:,
workflowStart(systemConfig)userGuide - 语义化命名:基于节点名称生成(移除空格和中文,转换为驼峰式)
- 唯一性保证:如果冲突,添加,
_1后缀_2
示例:
- →
generateNodeId('chatNode', '旅行规划助手')TravelPlanningAssistantNode - →
generateNodeId('httpRequest468', '天气查询')WeatherQueryNode - →
generateNodeId('chatNode', '助手', {TravelPlanningAssistantNode})AssistantNode_1
Position Auto-Layout Algorithm
位置自动布局算法
Algorithm: Hierarchical Layout
Steps:
- Topological sort to determine layers (BFS)
- Calculate horizontal position and vertical spacing for each layer
- Fixed position for special nodes (userGuide: {x: -600, y: -250})
Parameters:
- LAYER_GAP_X = 350 (horizontal spacing between layers)
- NODE_GAP_Y = 150 (vertical spacing within layer)
- START_X = -200, START_Y = 0
算法:分层布局
步骤:
- 拓扑排序确定层级(BFS)
- 计算每个层级的水平位置和垂直间距
- 特殊节点的固定位置(userGuide: {x: -600, y: -250})
参数:
- LAYER_GAP_X = 350(层级间的水平间距)
- NODE_GAP_Y = 150(层级内的垂直间距)
- START_X = -200, START_Y = 0
Reference Format Description
引用格式说明
Two Reference Formats:
1. Array Format (direct value reference):
json
"value": ["workflowStart", "userChatInput"]2. Template Syntax (string concatenation):
json
"value": "Please create a plan for me.\n\nDestination: {{$workflowStart.userChatInput$}}\n\nWeather: {{$weatherQueryNode.httpRawResponse$}}"Important: Template syntax is (double braces with single $)
{{$nodeId.key$}}两种引用格式:
1. 数组格式(直接值引用):
json
"value": ["workflowStart", "userChatInput"]2. 模板语法(字符串拼接):
json
"value": "请为我创建一份规划。\n\n目的地:{{$workflowStart.userChatInput$}}\n\n天气:{{$weatherQueryNode.httpRawResponse$}}"重要提示:模板语法为(双大括号加单个$)
{{$nodeId.key$}}Special Node Handling
特殊节点处理
loop Node:
- Must have field
childrenNodeIdList - Child nodes must have field
parentNodeId - Child nodes include: loopStart, [processing nodes...], loopEnd
ifElse Node:
- Has multiple output branches
- Each branch corresponds to different conditions
loop节点:
- 必须包含字段
childrenNodeIdList - 子节点必须包含字段
parentNodeId - 子节点包括:loopStart, [处理节点...], loopEnd
ifElse节点:
- 有多个输出分支
- 每个分支对应不同的条件
Best Practices
最佳实践
Do's (Recommended Practices)
推荐做法
- ✅ Always validate at three levels - format, connections, logic
- ✅ Use meaningful nodeIds - use semantic names (e.g., )
weatherQueryNode - ✅ Prefer template matching - template-based generation is more reliable than creating from scratch
- ✅ Use array references for direct values -
["nodeId", "key"] - ✅ Use template references for string concatenation -
{{$nodeId.key$}} - ✅ Auto-layout positions - use auto-layout algorithm
- ✅ Include system config node - always include userGuide
- ✅ Test with validation - use built-in validation before importing to FastGPT
- ✅ Provide clear error messages - include location and fix suggestions
- ✅ Document modifications - generate modification summary report
- ✅ 始终执行三层验证 - 格式、连接、逻辑
- ✅ 使用有意义的nodeId - 使用语义化名称(例如:)
weatherQueryNode - ✅ 优先使用模板匹配 - 基于模板生成比从零创建更可靠
- ✅ 直接值引用使用数组格式 -
["nodeId", "key"] - ✅ 字符串拼接使用模板引用 -
{{$nodeId.key$}} - ✅ 使用自动布局位置 - 使用自动布局算法
- ✅ 包含系统配置节点 - 始终包含userGuide
- ✅ 通过验证测试 - 导入FastGPT前使用内置验证
- ✅ 提供清晰的错误信息 - 包含位置和修复建议
- ✅ 记录修改内容 - 生成修改总结报告
Don'ts (Prohibited Practices)
禁止做法
- ❌ Don't skip validation - never skip validation
- ❌ Don't use invalid node types - check flowNodeType validity
- ❌ Don't create circular references without loop nodes - no illegal cycles
- ❌ Don't forget required fields - nodeId, name, flowNodeType, position, inputs, outputs
- ❌ Don't use wrong reference format - prohibited: (missing $)
{{nodeId.key}} - ❌ Don't ignore warnings - warnings should be fixed
- ❌ Don't hardcode positions - except userGuide, use auto-layout
- ❌ Don't create unreachable nodes - ensure reachable from workflowStart
- ❌ Don't generate overly complex workflows - workflows with >20 nodes should be split
- ❌ 不要跳过验证 - 绝不跳过验证
- ❌ 不要使用无效节点类型 - 检查flowNodeType的有效性
- ❌ 不要在未使用loop节点的情况下创建循环引用 - 无非法循环
- ❌ 不要遗漏必填字段 - nodeId, name, flowNodeType, position, inputs, outputs
- ❌ 不要使用错误的引用格式 - 禁止:(缺少$)
{{nodeId.key}} - ❌ 不要忽略警告 - 警告应被修复
- ❌ 不要硬编码位置 - 除userGuide外,使用自动布局
- ❌ 不要创建不可达节点 - 确保可从workflowStart到达
- ❌ 不要生成过于复杂的工作流 - 超过20个节点的工作流应拆分
Troubleshooting
故障排除
FAQ
常见问题
Q1: Import to FastGPT reports "Invalid node type"
A: Check the field, ensure using supported types. Reference . Common errors:
flowNodeTypereferences/node_types_reference.md- is correct (not
chatNode)aiChat - Number suffixes (like ) should be retained
httpRequest468
Q2: References between nodes not working
A: Check reference format:
- ✅ Correct: or
["workflowStart", "userChatInput"]{{$workflowStart.userChatInput$}} - ❌ Wrong: (single brace, should be double)
{$workflowStart.userChatInput$}
Q3: Some nodes not executing at runtime
A: Use built-in validation to check Level 3, ensure all nodes reachable from workflowStart
Q4: Parallel nodes not executing in parallel
A: Ensure multiple nodes' targets are the same aggregation node, and these nodes have no dependencies
Q5: Loop workflow errors
A: Must use node, configure and
flowNodeType: "loop"parentNodeIdchildrenNodeIdListQ1:导入FastGPT时提示“无效节点类型”
A:检查字段,确保使用支持的类型。参考。常见错误:
flowNodeTypereferences/node_types_reference.md- 是正确的(不是
chatNode)aiChat - 应保留数字后缀(例如)
httpRequest468
Q2:节点间的引用不生效
A:检查引用格式:
- ✅ 正确:或
["workflowStart", "userChatInput"]{{$workflowStart.userChatInput$}} - ❌ 错误:(单大括号,应为双大括号)
{$workflowStart.userChatInput$}
Q3:运行时部分节点未执行
A:使用内置验证检查第三层,确保所有节点可从workflowStart到达
Q4:并行节点未并行执行
A:确保多个节点的目标是同一个聚合节点,且这些节点之间无依赖关系
Q5:循环工作流出错
A:必须使用节点,配置和
flowNodeType: "loop"parentNodeIdchildrenNodeIdListDebug Checklist
调试检查清单
markdown
undefinedmarkdown
undefinedPhase 1: JSON Format Check
阶段1:JSON格式检查
- JSON is parseable
- Contains nodes, edges, chatConfig
- All strings use double quotes
- No trailing commas
- JSON可解析
- 包含nodes, edges, chatConfig
- 所有字符串使用双引号
- 无 trailing commas
Phase 2: Node Check
阶段2:节点检查
- workflowStart node exists
- At least one output node exists
- All flowNodeType valid
- All nodeId unique
- All position contains x, y
- workflowStart节点存在
- 至少有一个输出节点存在
- 所有flowNodeType有效
- 所有nodeId唯一
- 所有position包含x, y
Phase 3: Connection Check
阶段3:连接检查
- All edges' source and target exist
- All handle format correct
- No duplicate edges, no self-loops
- 所有edges的source和target存在
- 所有handle格式正确
- 无重复边,无自环
Phase 4: Reference Check
阶段4:引用检查
- All array references' nodes and keys exist
- All template references' nodes and keys exist
- Reference types match
- 所有数组引用的节点和键存在
- 所有模板引用的节点和键存在
- 引用类型匹配
Phase 5: Logic Check
阶段5:逻辑检查
- All nodes reachable from workflowStart
- No illegal cycles
- No dead-end nodes
- All required inputs have values
- 所有节点可从workflowStart到达
- 无非法循环
- 无死节点
- 所有必填输入都有值
Phase 6: Runtime Test
阶段6:运行时测试
- Import to FastGPT without errors
- Configure necessary parameters
- Run test cases
- Check output meets expectations
---- 导入FastGPT无错误
- 配置必要的参数
- 运行测试用例
- 检查输出符合预期
---Quick Reference
快速参考
Built-in Template Files
内置模板文件
- - Simple workflow, document processing
templates/文档翻译助手.json - - Medium complexity, conversational AI
templates/销售陪练大师.json - - Complex workflow, data + external integration
templates/简历筛选助手_飞书.json - - Scheduled trigger, multi-agent
templates/AI金融日报.json
- - 简单工作流,文档处理
templates/文档翻译助手.json - - 中等复杂度,对话式AI
templates/销售陪练大师.json - - 复杂工作流,数据+外部集成
templates/简历筛选助手_飞书.json - - 定时触发,多智能体
templates/AI金融日报.json
Detailed Documentation
详细文档
- - Complete reference of 40+ node types
references/node_types_reference.md - - Detailed three-layer validation rules
references/validation_rules.md - - Template matching algorithm
references/template_matching.md - - Complete FastGPT JSON structure specification
references/json_structure_spec.md
- - 40+种节点类型的完整参考
references/node_types_reference.md - - 三层验证规则的详细说明
references/validation_rules.md - - 模板匹配算法
references/template_matching.md - - 完整的FastGPT JSON结构规范
references/json_structure_spec.md
Example Documents
示例文档
- - Complete example: Simple Q&A workflow
examples/example1_simple_qa.md - - Complete example: Travel planning workflow
examples/example2_travel_planning.md - - Complete example: Incremental modification
examples/example3_incremental_modify.md
- - 完整示例:简单问答工作流
examples/example1_simple_qa.md - - 完整示例:旅行规划工作流
examples/example2_travel_planning.md - - 完整示例:增量修改
examples/example3_incremental_modify.md
Common Commands
常用命令
bash
undefinedbash
undefinedValidate workflow JSON
验证工作流JSON
node scripts/validate_workflow.js path/to/workflow.json
node scripts/validate_workflow.js path/to/workflow.json
Copy template
复制模板
cp templates/文档翻译助手.json my_workflow.json
cp templates/文档翻译助手.json my_workflow.json
View template list
查看模板列表
ls -lh templates/
---
**Version**: 1.0
**Last Updated**: 2025-01-02
**Compatibility**: FastGPT v4.8+ls -lh templates/
---
**版本**:1.0
**最后更新**:2025-01-02
**兼容性**:FastGPT v4.8+