8
n8n 中文网amn8n.com

简单 RAG

中级

这是一个Internal Wiki, AI RAG领域的自动化工作流,包含 14 个节点。主要使用 FormTrigger, Agent, ChatTrigger, LmChatOpenAi, RerankerCohere 等节点。 使用OpenAI、Pinecone和Cohere重排序构建基于PDF的RAG系统

前置要求
  • OpenAI API Key
  • Pinecone API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "pDhufDfHS9qRgtLf",
  "meta": {
    "instanceId": "fa52a98dd39f67760c7540fff8a0dd5306d89f766551eb7a7c84b5f43eb33d4c",
    "templateCredsSetupCompleted": true
  },
  "name": "简单 RAG",
  "tags": [],
  "nodes": [
    {
      "id": "93cd13c5-12ad-4c9c-aac7-1886a1d24470",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "webhookId": "cab3dda4-3b49-4f05-a2c1-915ae4c62017",
      "parameters": {
        "options": {},
        "formTitle": "Upload RAG PDF",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "File",
              "multipleFiles": false,
              "requiredField": true,
              "acceptFileTypes": ".pdf"
            }
          ]
        },
        "formDescription": "Upload RAG PDF"
      },
      "typeVersion": 2.2
    },
    {
      "id": "13fe2ba5-a24d-4198-8509-882eb4c08e1a",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        320,
        0
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n",
          "cachedResultName": "n8n"
        }
      },
      "credentials": {
        "pineconeApi": {
          "id": "VP5fhue9NYRkdlCj",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "aa3d1481-3da7-4ae1-9857-c64a71e28443",
      "name": "OpenAI 嵌入",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        920,
        460
      ],
      "parameters": {
        "options": {
          "dimensions": 1024
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "y8sLJ2LzZL2c7SGi",
          "name": "OpenAI Webinar"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "17350e15-5b99-493d-acd2-9f44fd661b09",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        440,
        220
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "8199713d-cad8-4d17-937c-1b3b604b95ea",
      "name": "递归字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        520,
        440
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "fcaf5178-4694-4e20-ac62-8da3c1c8279e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -80
      ],
      "parameters": {
        "width": 880,
        "height": 680,
        "content": "## 插入数据到 Pinecone"
      },
      "typeVersion": 1
    },
    {
      "id": "e094ded2-c2e9-4139-b6d0-df086f2e2049",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1440,
        80
      ],
      "parameters": {
        "options": {
          "systemMessage": "Hanya jawab berdasarkan data yang ada di tools \"VectorDB\". Kalau data disitu gak ada, jawab saja kamu tidak tahu."
        }
      },
      "typeVersion": 2
    },
    {
      "id": "015d2a82-3c3d-4604-bbbf-7df57dd24269",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1200,
        80
      ],
      "webhookId": "c1f8d15b-e096-47f8-922e-a7484ebbc25c",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "a1b26946-9a3f-4aa2-a723-f91e196943cf",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1280,
        300
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "y8sLJ2LzZL2c7SGi",
          "name": "OpenAI Webinar"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6beecd5e-a8fc-4e69-8fbc-a0e0e90c4aa6",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1480,
        300
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "02b1aa4f-a291-4f2c-b6d9-0290d6b563ae",
      "name": "向量数据库",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1640,
        300
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 20,
        "options": {},
        "useReranker": true,
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "n8n",
          "cachedResultName": "n8n"
        },
        "toolDescription": "Ambil data dari vector database untuk knowledgebase"
      },
      "credentials": {
        "pineconeApi": {
          "id": "VP5fhue9NYRkdlCj",
          "name": "PineconeApi account"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "bada58fc-73f4-431f-9702-e742a75ce2c3",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 860,
        "height": 680,
        "content": "## 聊天 AI Agent"
      },
      "typeVersion": 1
    },
    {
      "id": "2e572866-dcf7-492f-aebe-35b12bc6b27d",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        300
      ],
      "parameters": {
        "color": 4,
        "height": 300,
        "content": "## 嵌入模型"
      },
      "typeVersion": 1
    },
    {
      "id": "6dcbbf3a-3acd-4170-9f79-c2441da18979",
      "name": "Cohere 重排序器",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        1740,
        480
      ],
      "parameters": {},
      "credentials": {
        "cohereApi": {
          "id": "yDA2nh2ZZXkR9tcq",
          "name": "Cohere API Trial"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6b1d46bd-ed09-4a25-a95e-fa5a3e2950f7",
  "connections": {
    "VectorDB": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere": {
      "ai_reranker": [
        [
          {
            "node": "VectorDB",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "VectorDB",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store": {
      "main": [
        []
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内部知识库, AI RAG 检索增强

需要付费吗?

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

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

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

作者
Aji Prakoso

Aji Prakoso

@jipraks

Indonesian AI & Automation Enthusiast. Automating life using n8n.

外部链接
在 n8n.io 查看

分享此工作流