评估指标示例:检查工具是否被调用

中级

这是一个Engineering、AI领域的自动化工作流,包含 15 个节点。主要使用 Set、Evaluation、Agent、HttpRequestTool、EvaluationTrigger 等节点,结合人工智能技术实现智能自动化。 评估指标示例:检查工具是否被调用

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "bf40384a063e00f3b983f4f9bada22b57a8231a04c0fb48d363e26d7b0f2b7e7",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ffd0cca6-4a60-4058-b3fb-c92d949ea864",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -960,
        -120
      ],
      "parameters": {
        "options": {
          "returnIntermediateSteps": true
        }
      },
      "typeVersion": 1.9
    },
    {
      "id": "73055399-e667-45cb-8a32-accb83dd74f8",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1000,
        140
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Ag9qPAsY7lpIGkvC",
          "name": "JPs n8n openAI key"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "54ffa0e9-dbf7-4406-9952-485ca46d1172",
      "name": "计算器",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        -840,
        140
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "09dcce53-ce33-4263-b903-655db12d13dd",
      "name": "检查是否调用了工具",
      "type": "n8n-nodes-base.set",
      "position": [
        -340,
        -240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "58c48e6f-4a12-4bf6-94ae-705244273a84",
              "name": "tool_called",
              "type": "boolean",
              "value": "={{ $json.intermediateSteps.filter(x => x.action.tool == $('When fetching a dataset row').item.json.tool_to_call).length > 0 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "62fb0980-6c8e-4ab6-b914-59339b4b385f",
      "name": "获取网页",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -700,
        140
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', ``, 'string') }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "ec4c82df-8804-49f2-a8ba-348f29b97cd6",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -980,
        -200
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 220,
        "content": "确保在代理中启用\"返回中间步骤\",以获取已执行工具的列表"
      },
      "typeVersion": 1
    },
    {
      "id": "f6fa8aef-4362-4691-85fc-2612eb1dee63",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1440,
        -240
      ],
      "webhookId": "c4dc43bf-4625-4821-bd9d-ca22a2f34170",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "d1274230-aa4d-4456-93ea-8123e263df7d",
      "name": "匹配聊天格式",
      "type": "n8n-nodes-base.set",
      "position": [
        -1220,
        40
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e6e064bb-ac06-40ca-97bf-42f682b30065",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.question }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "474a2321-7a4c-41be-a8fa-718f5a093171",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        -320
      ],
      "parameters": {
        "color": 7,
        "width": 180,
        "height": 240,
        "content": "检查已执行工具列表是否包含目标工具"
      },
      "typeVersion": 1
    },
    {
      "id": "3351706d-e7e9-4701-9224-b4c873167c0d",
      "name": "返回聊天响应",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -340,
        40
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e7beb2d8-f864-4aea-84f2-0d82987f52f8",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1740,
        -280
      ],
      "parameters": {
        "width": 200,
        "height": 500,
        "content": "## 工作原理"
      },
      "typeVersion": 1
    },
    {
      "id": "a990cca2-7ea5-4d43-9cc2-b6257299bcc1",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1500,
        -60
      ],
      "parameters": {
        "color": 7,
        "width": 220,
        "height": 260,
        "content": "读取此测试数据集,其中包含问题以及回答时应调用的工具"
      },
      "typeVersion": 1
    },
    {
      "id": "f0f7e18c-029f-4e0a-ac2f-168e10b5f51f",
      "name": "当获取数据集行时",
      "type": "n8n-nodes-base.evaluationTrigger",
      "position": [
        -1440,
        40
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/1uuPS5cHtSNZ6HNLOi75A2m8nVWZrdBZ_Ivf58osDAS8/edit?gid=969651976#gid=969651976"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/1uuPS5cHtSNZ6HNLOi75A2m8nVWZrdBZ_Ivf58osDAS8/edit?gid=969651976#gid=969651976"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "bpr2LoSELMlxpwnN",
          "name": "Google Sheets account David"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "e0c49dc5-a06b-4552-b53c-e5dfc51017e0",
      "name": "评估",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        -120,
        -240
      ],
      "parameters": {
        "metrics": {
          "assignments": [
            {
              "id": "66ed21d5-a10a-47a3-993d-459aa4a4fbba",
              "name": "tool_called",
              "type": "number",
              "value": "={{ $json.tool_called.toNumber() }}"
            }
          ]
        },
        "operation": "setMetrics"
      },
      "typeVersion": 4.6
    },
    {
      "id": "5b14c47b-2dae-4ca7-882c-d0ec722eadab",
      "name": "正在评估?",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        -580,
        -120
      ],
      "parameters": {
        "operation": "checkIfEvaluating"
      },
      "typeVersion": 4.6
    }
  ],
  "pinData": {},
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Evaluating?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Evaluating?": {
      "main": [
        [
          {
            "node": "Check if tool called",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return chat response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch a webpage": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Match chat format": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check if tool called": {
      "main": [
        [
          {
            "node": "Evaluation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When fetching a dataset row": {
      "main": [
        [
          {
            "node": "Match chat format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个中级难度的工作流,适用于Engineering、AI等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

需要付费吗?

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

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

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

外部链接
在 n8n.io 上查看 →

分享此工作流