8
n8n 中文网amn8n.com

使用多模型问答工具节省RAG工作流成本

中级

这是一个Building Blocks, AI领域的自动化工作流,包含 13 个节点。主要使用 FormTrigger, Agent, ChatTrigger, LmChatOpenAi, ToolVectorStore 等节点,结合人工智能技术实现智能自动化。 使用多模型问答工具节省RAG工作流成本

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "257476b1ef58bf3cb6a46e65fac7ee34a53a5e1a8492d5c6e4da5f87c9b82833",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "83ed351e-90e8-458f-a01b-73001ef1800f",
      "name": "在此处上传您的文件",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        220,
        -120
      ],
      "webhookId": "82848bc4-5ea2-4e5a-8bb6-3c09b94a8c5d",
      "parameters": {
        "options": {},
        "formTitle": "Upload your data to test RAG",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Upload your file(s)",
              "requiredField": true,
              "acceptFileTypes": ".pdf, .csv"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "26d63e24-2592-41f9-9b4b-edab81e99f21",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        860,
        460
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "14",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3a69c8a7-bf95-4de2-84b0-ae2cc3d2e4e7",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        660,
        40
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0b42832b-c9e8-4627-b36c-94fc5e242b33",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -180
      ],
      "parameters": {
        "color": 4,
        "width": 440,
        "height": 300,
        "content": "### 自述文件"
      },
      "typeVersion": 1
    },
    {
      "id": "f902ab8f-4620-4a95-86f7-c5857c4d6c4f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 460,
        "content": "### 📚 加载数据流程"
      },
      "typeVersion": 1
    },
    {
      "id": "0f4185ea-d7a9-44a9-a824-98f9dc2c2a5d",
      "name": "将数据插入存储",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        400,
        -120
      ],
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key",
          "cachedResultName": "vector_store_key"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ce86b41b-7e1b-458f-ab13-d6b187854ae8",
      "name": "查询数据工具",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        1300,
        200
      ],
      "parameters": {
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0039537b-558c-4fe8-9716-f8aa13676f4a",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1280,
        -140
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "2669a65e-f0f3-45aa-95c0-621b15a4fc67",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1060,
        -140
      ],
      "webhookId": "4091fa09-fb9a-4039-9411-7104d213f601",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "3d1b3f5a-bc35-4739-a618-9c85820d39a0",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        940,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 820,
        "height": 520,
        "content": "### 🐕 2. 检索器流程"
      },
      "typeVersion": 1
    },
    {
      "id": "6553a758-c655-4196-88be-9d93187f9c7b",
      "name": "使用向量存储回答问题",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "position": [
        1440,
        60
      ],
      "parameters": {
        "description": "数据包含自定义知识"
      },
      "typeVersion": 1.1
    },
    {
      "id": "d43cf585-4192-4f53-9532-4677923289ba",
      "name": "昂贵模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1060,
        80
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "14",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "18dcc49d-9ce0-4746-8135-7e4c77cfa501",
      "name": "廉价模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1600,
        200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "14",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "pinData": {},
  "connections": {
    "Cheap Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Expensive model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Query Data Tool": {
      "ai_tool": [
        []
      ],
      "ai_vectorStore": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Insert Data to Store",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Query Data Tool",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Insert Data to Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Upload your file here": {
      "main": [
        [
          {
            "node": "Insert Data to Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer questions with a vector store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 构建模块, 人工智能

需要付费吗?

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

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

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

作者
Niklas Hatje

Niklas Hatje

@nik8n

Product Manager at n8n - Responsible for the creator program

外部链接
在 n8n.io 查看

分享此工作流