8
n8n 中文网amn8n.com

使用Ecologits.ai方法测量AI模型碳足迹

中级

这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 7 个节点。主要使用 Set, ManualTrigger, ChainLlm, LmChatOpenAi 等节点。 使用Ecologits.ai方法测量AI模型碳足迹

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "nodes": [
    {
      "id": "e374f8b8-ff4a-4b98-af50-d609338ec38f",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        -160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "6cce6b66-bd1a-419b-86c1-b76aa257e96c",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        608,
        -160
      ],
      "parameters": {
        "text": "Enter here your user prompt",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "Enter here the system prompt"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "d0ea8139-307d-4de6-9f29-11216958f362",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        672,
        64
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "dMiSy27YCK6c6rra",
          "name": "Duv's OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0fca2f27-8a0b-46d0-9dfc-27967afe2ae5",
      "name": "计算 gCO₂e",
      "type": "n8n-nodes-base.set",
      "position": [
        960,
        -160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cc17f2be-ce12-488f-89c7-de200b4c4869",
              "name": "AI output",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "c396e3b8-f07f-4153-9892-1b499a724dbc",
              "name": "AI output gCO₂e",
              "type": "number",
              "value": "={{ Math.ceil($json.text.length / 4) * $('Conversion factor').item.json['Conversion factor (in gCO₂e/token)'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5c25ded0-c24d-455b-82fb-d54d267ca591",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        -384
      ],
      "parameters": {
        "width": 560,
        "height": 672,
        "content": "# 测量您 AI 的碳足迹"
      },
      "typeVersion": 1
    },
    {
      "id": "941043b0-01ee-4553-87ec-1246a4cb2f2b",
      "name": "转换因子",
      "type": "n8n-nodes-base.set",
      "position": [
        304,
        -160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a2c5484b-173e-4647-8dc1-23c32a899f75",
              "name": "Conversion factor (in gCO₂e/token)",
              "type": "number",
              "value": 0.0612
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "430fc390-50b7-4feb-8c8f-be196a342d60",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 272,
        "height": 336,
        "content": "### 根据您的模型和设置调整此值"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Calculate gCO₂e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversion factor": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Conversion factor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - AI 摘要总结, 多模态 AI

需要付费吗?

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

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

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

作者
Guillaume Duvernay

Guillaume Duvernay

@duv

AI and automation expert

外部链接
在 n8n.io 查看

分享此工作流