RAG 重排序
高级
这是一个Internal Wiki, AI RAG领域的自动化工作流,包含 26 个节点。主要使用 Code, GoogleDrive, ManualTrigger, Agent, ExtractFromFile 等节点。 使用 Supabase、OpenAI 和 Cohere 重排序器从文档中回答问题
前置要求
- •Google Drive API 凭证
- •OpenAI API Key
- •Supabase URL 和 API Key
使用的节点 (26)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "p8bHqYEvjtOrvz3q",
"meta": {
"instanceId": "",
"templateCredsSetupCompleted": true
},
"name": "RAG 重排序",
"tags": [],
"nodes": [
{
"id": "d690d954-6291-4355-9b51-42fe9ab2791a",
"name": "下载文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
-100,
-320
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "list",
"value": "16ahWlNwBvd53xFHA4UUh6EbkFd8ogxBv",
"cachedResultUrl": "https://drive.google.com/file/d/16ahWlNwBvd53xFHA4UUh6EbkFd8ogxBv/view?usp=drivesdk",
"cachedResultName": "Rules_of_Golf_Simplified.pdf"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "V2ewjiHO0o6xhQ2R",
"name": "nateherk88@gmail.com"
}
},
"typeVersion": 3
},
{
"id": "ad9a4d3c-ace1-428c-8957-edb456bf864f",
"name": "默认数据加载器",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
460,
-180
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "ruleNumber",
"value": "={{ $json.ruleNumber }}"
}
]
}
},
"jsonData": "={{ $('Code').item.json.fullText }}",
"jsonMode": "expressionData"
},
"typeVersion": 1.1
},
{
"id": "f6d44c38-8cb4-43ad-8130-7ab8cd142c9a",
"name": "从文件提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
40,
-320
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "dfc604ab-b7bd-4a08-b65d-f8fe2c3b5c13",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
180,
-320
],
"parameters": {
"jsCode": "// n8n Code Node - Split Golf Rules\n// This code takes the input text and splits it into separate items for each rule\n\n// Get the input text from the first item\nconst inputText = $input.first().json.text;\n\n// Split the text by \"Rule\" pattern, keeping the \"Rule\" text with each section\nconst ruleSections = inputText.split(/(?=Rule \\d+)/);\n\n// Remove the first empty element (everything before the first \"Rule\")\nconst cleanedSections = ruleSections.filter(section => section.trim().startsWith('Rule'));\n\n// Create output items - one for each rule\nconst outputItems = cleanedSections.map((ruleText, index) => {\n // Extract rule number from the text\n const ruleMatch = ruleText.match(/Rule (\\d+)/);\n const ruleNumber = ruleMatch ? ruleMatch[1] : (index + 1).toString();\n \n // Extract rule title (everything between \"Rule X –\" and the first numbered item)\n const titleMatch = ruleText.match(/Rule \\d+ – (.+?)(?=\\n1\\.|\\n\\d+\\.)/);\n const ruleTitle = titleMatch ? titleMatch[1].trim() : 'Unknown Rule';\n \n return {\n json: {\n ruleNumber: ruleNumber,\n ruleTitle: ruleTitle,\n fullText: ruleText.trim(),\n originalIndex: index\n }\n };\n});\n\nreturn outputItems;"
},
"typeVersion": 2
},
{
"id": "cc659be4-709e-4d59-a386-d7cc60166293",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-280,
-1180
],
"webhookId": "79772045-628b-4cf6-b2ec-cecceca9fe24",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "9f02235d-8c3f-4309-bd14-d4c6bcdfab11",
"name": "GPT 4.1-mini",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
-100,
-1040
],
"parameters": {
"options": {}
},
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
},
"typeVersion": 1
},
{
"id": "dad869f9-4c1d-44a4-b523-31f007efccc7",
"name": "Cohere重新排序器",
"type": "@n8n/n8n-nodes-langchain.rerankerCohere",
"position": [
520,
-1040
],
"parameters": {},
"credentials": {
"cohereApi": {
"id": "vCsqiDhFNdSGhDKu",
"name": "CohereApi account"
}
},
"typeVersion": 1
},
{
"id": "24cbdd3d-afee-46d2-83ef-888d432b4874",
"name": "上传到 Supabase",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
320,
-320
],
"parameters": {
"mode": "insert",
"options": {
"queryName": "match_documents"
},
"tableName": {
"__rl": true,
"mode": "list",
"value": "documents",
"cachedResultName": "documents"
}
},
"credentials": {
"supabaseApi": {
"id": "r1eLu64ie9Tz6yOK",
"name": "Demo 2.22.25"
}
},
"typeVersion": 1.3
},
{
"id": "f80184cb-fc7e-40d7-bf2d-a723350c9f0f",
"name": "Supabase向量存储",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
360,
-1180
],
"parameters": {
"mode": "retrieve-as-tool",
"topK": 20,
"options": {},
"tableName": {
"__rl": true,
"mode": "list",
"value": "documents",
"cachedResultName": "documents"
},
"useReranker": true,
"toolDescription": "Use this tool to search the database"
},
"credentials": {
"supabaseApi": {
"id": "r1eLu64ie9Tz6yOK",
"name": "Demo 2.22.25"
}
},
"typeVersion": 1.3
},
{
"id": "de08fce1-3db6-4452-a30a-27294328bdb9",
"name": "GPT 4.1-mini1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
220,
-600
],
"parameters": {
"options": {}
},
"credentials": {
"openRouterApi": {
"id": "fpo6OUh9TcHg29jk",
"name": "OpenRouter account"
}
},
"typeVersion": 1
},
{
"id": "2fbb1dbc-aeb3-4f5d-b1b1-f8947bec45e4",
"name": "Cohere重新排序器1",
"type": "@n8n/n8n-nodes-langchain.rerankerCohere",
"position": [
780,
-620
],
"parameters": {},
"credentials": {
"cohereApi": {
"id": "vCsqiDhFNdSGhDKu",
"name": "CohereApi account"
}
},
"typeVersion": 1
},
{
"id": "64140fce-9e7c-4cd2-a5ba-2bfb4c8bdaad",
"name": "OpenAI嵌入2",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
620,
-620
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "WnxUhaEPMn5hIsEp",
"name": "Demo 4/2"
}
},
"typeVersion": 1.2
},
{
"id": "fe882466-73db-4141-8c70-baff299b4e1c",
"name": "Supabase 向量存储1",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
620,
-760
],
"parameters": {
"mode": "retrieve-as-tool",
"topK": 20,
"options": {
"metadata": {
"metadataValues": [
{
"name": "ruleNumber",
"value": "={{ $('Metadata Agent').item.json.output }}"
}
]
}
},
"tableName": {
"__rl": true,
"mode": "list",
"value": "documents",
"cachedResultName": "documents"
},
"useReranker": true,
"toolDescription": "Use this tool to search the database"
},
"credentials": {
"supabaseApi": {
"id": "r1eLu64ie9Tz6yOK",
"name": "Demo 2.22.25"
}
},
"typeVersion": 1.3
},
{
"id": "12e4fe9d-d97d-4252-a235-66017fadad66",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
-460
],
"parameters": {
"color": 2,
"width": 1000,
"height": 440,
"content": "# 带元数据的文档向量化"
},
"typeVersion": 1
},
{
"id": "406521ff-0f01-4688-a352-62ae49d71ff6",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
-1280
],
"parameters": {
"color": 4,
"width": 620,
"height": 380,
"content": "# RAG 智能体"
},
"typeVersion": 1
},
{
"id": "11f6a7fd-b540-43d9-ad55-86c2874e8ddd",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
300,
-1280
],
"parameters": {
"color": 5,
"width": 380,
"height": 380,
"content": "## 带重排序器的向量存储"
},
"typeVersion": 1
},
{
"id": "d295d851-b64b-41c9-9289-f7c5c640b704",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
300,
-180
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "WnxUhaEPMn5hIsEp",
"name": "Demo 4/2"
}
},
"typeVersion": 1.2
},
{
"id": "5b11e4ea-c497-4d18-8dfe-3dcdcadde1e6",
"name": "Embeddings OpenAI",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
360,
-1040
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "WnxUhaEPMn5hIsEp",
"name": "Demo 4/2"
}
},
"typeVersion": 1.2
},
{
"id": "62282da2-0dc5-4758-8182-13a7bf1afff9",
"name": "元数据智能体",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-220,
-760
],
"parameters": {
"options": {
"systemMessage": "=# Overview\nYour job is to understand the rule number that the human is requesting and output only the number.\n\n## Example\nInput - what's rule number 27?\nOutput - 27"
}
},
"typeVersion": 2
},
{
"id": "9fbd11cd-195d-4bbe-aa81-718c063d1133",
"name": "RAG Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-80,
-1180
],
"parameters": {
"options": {
"systemMessage": "=# Overview\nYou are an AI agent who is an expert at the rules of golf. You will receive a question from the human, and you must use your tool called \"Supabase Vector Store\" in order to retrieve information from the database to make sure you are answering the question accurately. "
}
},
"typeVersion": 2
},
{
"id": "150a92c9-fdb4-45e0-a838-45364dd6140b",
"name": "RAG 智能体 2",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
200,
-760
],
"parameters": {
"text": "={{ $('When chat message received').item.json.chatInput }}",
"options": {
"systemMessage": "=# Overview\nYou are an AI agent who is an expert at the rules of golf. You will receive a question from the human, and you must use your tool called \"Supabase Vector Store\" in order to retrieve information from the database to make sure you are answering the question accurately. "
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "e149b963-2f39-472b-962a-12bdd270e63b",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
120,
-880
],
"parameters": {
"color": 4,
"width": 440,
"height": 400,
"content": "# RAG 智能体"
},
"typeVersion": 1
},
{
"id": "ede1b0d8-d402-4fa5-abe0-8ee4169be45b",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
-880
],
"parameters": {
"color": 5,
"width": 380,
"height": 400,
"content": "## 带重排序器和元数据的向量存储"
},
"typeVersion": 1
},
{
"id": "c56cce9d-2d8c-4942-94fa-a8d62e062842",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
-880
],
"parameters": {
"color": 6,
"width": 440,
"height": 400,
"content": "# 元数据智能体"
},
"typeVersion": 1
},
{
"id": "7e6dd534-9f8a-42c2-bac0-0bb0e4fa99e6",
"name": "手动触发器",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-240,
-320
],
"parameters": {},
"typeVersion": 1
},
{
"id": "85ee82ce-f0b2-49f0-852e-9b888b9235a9",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1040,
-1280
],
"parameters": {
"width": 700,
"height": 800,
"content": "# 🛠️ 设置指南"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "80eccd78-53ac-4cca-aedd-63ddf77ff7af",
"connections": {
"Code": {
"main": [
[
{
"node": "Upload to Supabase",
"type": "main",
"index": 0
}
]
]
},
"GPT 4.1-mini": {
"ai_languageModel": [
[
{
"node": "RAG Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Download File": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"GPT 4.1-mini1": {
"ai_languageModel": [
[
{
"node": "RAG Agent 2",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Metadata Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Download File",
"type": "main",
"index": 0
}
]
]
},
"Metadata Agent": {
"main": [
[
{
"node": "RAG Agent 2",
"type": "main",
"index": 0
}
]
]
},
"Reranker Cohere": {
"ai_reranker": [
[
{
"node": "Supabase Vector Store",
"type": "ai_reranker",
"index": 0
}
]
]
},
"Reranker Cohere1": {
"ai_reranker": [
[
{
"node": "Supabase Vector Store1",
"type": "ai_reranker",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Upload to Supabase",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI2": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Upload to Supabase",
"type": "ai_document",
"index": 0
}
]
]
},
"Supabase Vector Store": {
"ai_tool": [
[
{
"node": "RAG Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Supabase Vector Store1": {
"ai_tool": [
[
{
"node": "RAG Agent 2",
"type": "ai_tool",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "RAG Agent",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 内部知识库, AI RAG 检索增强
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
构建集成Claude、RAG、Perplexity和Drive的全源知识助手
构建集成Claude、RAG、Perplexity和Drive的全源知识助手
Set
Switch
Google Drive
+21
38 节点Paul
内部知识库
基于文档的 AI 聊天机器人,带 RAG、OpenAI 和 Cohere 重排器
基于文档的 AI 聊天机器人,带 RAG、OpenAI 和 Cohere 重排器
Google Drive
Manual Trigger
Agent
+9
18 节点Anderson Adelino
内部知识库
递归混合RAG 1
使用Google Drive、OpenAI和Gemini RAG进行递归分块的文档处理
Set
Code
Switch
+18
25 节点Mohsin Ali
内部知识库
重新排序 #1
使用Apify、GPT-4o和WhatsApp自动化销售冷呼叫管道
Set
Code
Webhook
+18
48 节点Khairul Muhtadin
客户培育
Telegram AI支持聊天机器人(多模态输入)
使用GPT-4和Supabase RAG创建多模态Telegram支持机器人
If
Set
Code
+17
51 节点Ezema Kingsley Chibuzo
客服机器人
文档 RAG 和聊天代理:Google Drive 到 Qdrant 与 Mistral OCR
文档 RAG 和聊天代理:Google Drive 到 Qdrant 与 Mistral OCR
If
Set
Code
+16
40 节点DIGITAL BIZ TECH
内部知识库