8
n8n 中文网amn8n.com

多智能体反馈循环

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 If, Set, Code, ManualTrigger, SplitInBatches 等节点。 基于GPT-4多智能体反馈系统的迭代内容优化

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "rdQbhY9lEyDizxvy",
  "meta": {
    "instanceId": "205780d3749915e5b72849aad8492ed96140f3a3cf0d7f077a27e6df51ded409",
    "templateCredsSetupCompleted": true
  },
  "name": "多智能体反馈循环",
  "tags": [
    {
      "id": "o58aq7CrdbXQHYA0",
      "name": "template",
      "createdAt": "2025-06-14T10:20:41.387Z",
      "updatedAt": "2025-06-14T10:20:41.387Z"
    }
  ],
  "nodes": [
    {
      "id": "74337855-c422-4186-9510-ce899d67e39f",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1180,
        240
      ],
      "parameters": {
        "text": "=Product: {{$json[\"productDescription\"]}}",
        "options": {
          "systemMessage": "You are a creative branding agent. Based on this product description, generate 3 distinct name + tagline options.\n\nReturn your output in this format:\n[\n  { \"name\": \"Name1\", \"tagline\": \"Tagline1\" },\n  { \"name\": \"Name2\", \"tagline\": \"Tagline2\" },\n  { \"name\": \"Name3\", \"tagline\": \"Tagline3\" }\n]\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "e056b2fa-3e6f-4fa7-b908-dba91d01ec61",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -780,
        240
      ],
      "parameters": {
        "options": {
          "reset": true
        }
      },
      "typeVersion": 3
    },
    {
      "id": "f7c4971f-1ea8-4448-ab73-35d945d76604",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        -360,
        360
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "595ebd64-59de-470c-9827-24d204db58f9",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.turn }}",
              "rightValue": 5
            },
            {
              "id": "fb2ec186-4676-4e91-85b1-af7ce745b203",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.done }}",
              "rightValue": "Yes"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b8c57f43-6f23-4e05-81c0-6c1db0264f18",
      "name": "评审智能体",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -120,
        420
      ],
      "parameters": {
        "text": "=Ideas:\n{{JSON.stringify($('Edit Fields').item.json.ideas)}}",
        "options": {
          "systemMessage": "You are a critical branding analyst. For each name + tagline below, provide a short flaw summary and a suggestion for improvement."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "cdcab121-8082-4295-aa7f-475bde50414e",
      "name": "优化智能体",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        320,
        520
      ],
      "parameters": {
        "text": "=**Original Ideas:** {{ JSON.stringify($('Edit Fields').item.json.ideas) }}\n\n**Critics Feedback:** {{ $json.output }}",
        "options": {
          "systemMessage": "You are a refiner. Use the original ideas and the critic’s feedback to create 3 improved name + tagline combinations.\n\nBe concise, clever, and impactful.\n\nReturn your output in this format:\n[\n  { \"name\": \"Name1\", \"tagline\": \"Tagline1\" },\n  { \"name\": \"Name2\", \"tagline\": \"Tagline2\" },\n  { \"name\": \"Name3\", \"tagline\": \"Tagline3\" }\n]\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "9a63dab8-269c-4073-bdf5-8661fcbfdc82",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -560,
        360
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1c6c6fc2-96de-469a-b30f-7ffae52c9847",
              "name": "ideas",
              "type": "array",
              "value": "={{ $json.output }}"
            },
            {
              "id": "1a857aee-ae3f-4e81-a09c-a9e83edd9b98",
              "name": "turn",
              "type": "number",
              "value": "={{ $json.turn || 1}}"
            },
            {
              "id": "d310985b-59a3-44b8-aa5a-e77f2b352ae4",
              "name": "done",
              "type": "string",
              "value": "={{ $json.done || \"No\"}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cdf532b0-6dd9-43e6-a1b2-76edb177e9fa",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        1180,
        880
      ],
      "parameters": {
        "jsCode": "const ideas = $json.output.ideas || [];\nconst currentTurn = $json.output.turn ?? 0;\nconst currentDone = $json.output.done || \"No\";\n\nconst nextTurn = currentTurn + 1;\n\nreturn [\n  {\n    json: {\n      ideas,\n      turn: nextTurn,\n      done: currentDone\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6d853089-99d1-4ee9-bd80-34ebcc2fd5a3",
      "name": "编辑字段1",
      "type": "n8n-nodes-base.set",
      "position": [
        1400,
        880
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "21a77915-3d73-450d-bc9c-f655471a3b56",
              "name": "output",
              "type": "array",
              "value": "={{ $json.ideas }}"
            },
            {
              "id": "6dee88ae-c3f3-464a-a3cc-179bd28b7c5e",
              "name": "turn",
              "type": "number",
              "value": "={{ $json.turn }}"
            },
            {
              "id": "2f2caa57-797c-4fa3-9126-da46777a2b63",
              "name": "done",
              "type": "string",
              "value": "={{ $json.done }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3702b8fc-61e2-4d01-aa10-0ddb5bff48c7",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -100,
        800
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "oPvbzpxkrzwKpKeY",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "17809998-4a9c-41d9-984e-c17cc24e7769",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        880,
        820
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"ideas\": [\n      { \"name\": \"EnterpriseMind\", \"tagline\": \"Harness AI to transform your business ideas into reality.\" },\n      { \"name\": \"InnoLogix\", \"tagline\": \"Capture and evolve your entrepreneurial ideas with AI-powered journaling.\" },\n      { \"name\": \"VentureScript\", \"tagline\": \"Document and accelerate your startup journey with intelligent AI journaling.\" }],\n  \"done\": \"Yes\",\n  \"turn\": 2\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "b47e29f2-bd26-4e9f-813f-2983b1841d33",
      "name": "当点击“执行工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1360,
        240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7d996197-5542-4d89-8c58-ced050c7fffc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1920,
        120
      ],
      "parameters": {
        "color": 5,
        "width": 3920,
        "height": 1160,
        "content": "# ⚙️ 设置指南"
      },
      "typeVersion": 1
    },
    {
      "id": "d64015c8-17f1-4fcc-a12f-f29d2ac0aa75",
      "name": "评估智能体",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        700,
        640
      ],
      "parameters": {
        "text": "=**Results To Examine:** {{ $json.output }}\n\n**Turns Through Loop:** {{ $('Edit Fields').item.json.turn }}",
        "options": {
          "systemMessage": "You are an evaluator. Rank the 3 improved name ideas and taglines. Recommend if the names and taglines are so awesome that it would make anyone want to purchase from this company, or further improvement is needed (Yes/No). Output a JSON that follows this format:\n{\n\t\"ideas\": [\n      { \"name\": \"EnterpriseMind\", \"tagline\": \"Harness AI to transform your business ideas into reality.\" },\n      { \"name\": \"InnoLogix\", \"tagline\": \"Capture and evolve your entrepreneurial ideas with AI-powered journaling.\" },\n      { \"name\": \"VentureScript\", \"tagline\": \"Document and accelerate your startup journey with intelligent AI journaling.\" }],\n  \"done\": \"Yes\",\n  \"turn\": 2\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "40c2c451-49fd-4266-94e1-3b66cabf6ebc",
  "connections": {
    "If": {
      "main": [
        [],
        [
          {
            "node": "Critic Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Critic Agent": {
      "main": [
        [
          {
            "node": "Refiner Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refiner Agent": {
      "main": [
        [
          {
            "node": "Evaluation agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evaluation agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Critic Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Refiner Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Evaluation agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Evaluation agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量13
分类2
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流