使用 Qdrant 的完整 RAG 系统,带自动来源引用
高级
这是一个AI, IT Ops领域的自动化工作流,包含 29 个节点。主要使用 Set, Code, Wait, Merge, Aggregate 等节点,结合人工智能技术实现智能自动化。 使用Qdrant、Gemini和OpenAI构建带自动引用的RAG系统
前置要求
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
- •Qdrant 服务器连接信息
- •Google Gemini API Key
使用的节点 (29)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "OAvKQCYsly0DTlci",
"meta": {
"instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462",
"templateCredsSetupCompleted": true
},
"name": "使用 Qdrant 的完整 RAG 系统,带自动来源引用",
"tags": [],
"nodes": [
{
"id": "65d3e882-ef84-4b3b-88b0-bb69bbe6886f",
"name": "点击“测试工作流”时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-400,
220
],
"parameters": {},
"typeVersion": 1
},
{
"id": "db531b5a-588a-4982-aa00-e565d6f5610b",
"name": "OpenAI1 嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
940,
480
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "4zwP0MSr8zkNvvV9",
"name": "OpenAi account"
}
},
"typeVersion": 1.1
},
{
"id": "5a1606d8-d851-4fb1-a18a-a45f5de3adf2",
"name": "默认数据加载器1",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1080,
480
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "file_id",
"value": "={{ $('Get file').item.json.id }}"
},
{
"name": "file_name",
"value": "={{ $('Get file').item.json.name }}"
}
]
}
},
"dataType": "binary",
"binaryMode": "specificField"
},
"typeVersion": 1
},
{
"id": "9923f6be-c2a5-4498-9fd2-0ed74ccdab35",
"name": "Qdrant 向量存储",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
1000,
240
],
"parameters": {
"mode": "insert",
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "negozio-emporio-verde",
"cachedResultName": "negozio-emporio-verde"
}
},
"credentials": {
"qdrantApi": {
"id": "iyQ6MQiVaF3VMBmt",
"name": "QdrantApi account (Hetzner)"
}
},
"typeVersion": 1
},
{
"id": "db1f5e71-28ef-427e-8911-275ddea4e44f",
"name": "创建集合",
"type": "n8n-nodes-base.httpRequest",
"position": [
-180,
-140
],
"parameters": {
"url": "http://QDRANTURL/collections/COLLECTION",
"method": "PUT",
"options": {},
"jsonBody": "{\n \"vectors\": {\n \"size\": 1536,\n \"distance\": \"Cosine\" \n },\n \"shard_number\": 1, \n \"replication_factor\": 1, \n \"write_consistency_factor\": 1 \n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "qhny6r5ql9wwotpn",
"name": "Qdrant API (Hetzner)"
}
},
"typeVersion": 4.2
},
{
"id": "e0936863-4ece-429c-bf32-49f75b5c8bf0",
"name": "递归字符文本分割器",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
1060,
660
],
"parameters": {
"options": {},
"chunkSize": 500,
"chunkOverlap": 50
},
"typeVersion": 1
},
{
"id": "1311350d-75d3-4edc-8fa9-584a1c36da6d",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
420,
220
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "1f9b623c-4e93-44da-8c9d-cfe9f5d5be9a",
"name": "等待",
"type": "n8n-nodes-base.wait",
"position": [
1380,
240
],
"webhookId": "89248db2-59f2-4b61-9cd5-71406144efee",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "22aacdc0-8ec5-42e2-b9a0-fb9e5a4aa23c",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-460,
1080
],
"webhookId": "c9460030-9e23-41c4-9fcd-6c4c7fadf784",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "1e132fba-00a5-414a-8f37-f34645f668ff",
"name": "Question and Answer Chain",
"type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
"position": [
120,
1280
],
"parameters": {
"options": {}
},
"typeVersion": 1.5
},
{
"id": "badee75e-bca7-49e4-9095-c098cb7adcab",
"name": "Google Gemini聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
0,
1500
],
"parameters": {
"options": {},
"modelName": "models/gemini-1.5-flash"
},
"credentials": {
"googlePalmApi": {
"id": "0p34rXqIqy8WuoPg",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "ad8cec62-ce1d-4e58-8e40-9a7a9f4f93c7",
"name": "Vector Store Retriever",
"type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
"position": [
160,
1500
],
"parameters": {
"topK": 5
},
"typeVersion": 1
},
{
"id": "0c7d1804-4525-4117-a19d-f2d59195fd47",
"name": "Qdrant 向量存储1",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
40,
1680
],
"parameters": {
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "negozio-emporio-verde",
"cachedResultName": "negozio-emporio-verde"
}
},
"credentials": {
"qdrantApi": {
"id": "iyQ6MQiVaF3VMBmt",
"name": "QdrantApi account (Hetzner)"
}
},
"typeVersion": 1.1
},
{
"id": "6cfe7e8a-e593-4e4e-a0be-3379dd85c748",
"name": "OpenAI 嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
20,
1880
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "4zwP0MSr8zkNvvV9",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "d9aa08b5-ed04-4506-9a2e-f994d4694f48",
"name": "嵌入 OpenAI4",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
100,
1140
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "4zwP0MSr8zkNvvV9",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "d0d32470-b1df-40ec-aac1-32e4c9cf2e4e",
"name": "合并1",
"type": "n8n-nodes-base.merge",
"position": [
640,
1140
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineAll"
},
"typeVersion": 3.1
},
{
"id": "2edbca72-220e-45a6-8295-830d58611549",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
460,
940
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "document.metadata.file_id"
},
{
"fieldToAggregate": "document.metadata.file_name"
}
]
}
},
"typeVersion": 1
},
{
"id": "8d116bc2-73d8-4349-8b4e-8dc0aef7cfa3",
"name": "清除集合",
"type": "n8n-nodes-base.httpRequest",
"position": [
-140,
220
],
"parameters": {
"url": "http://QDRANTURL/collections/COLLECTION/points/delete",
"method": "POST",
"options": {},
"jsonBody": "{\n \"filter\": {}\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "qhny6r5ql9wwotpn",
"name": "Qdrant API (Hetzner)"
}
},
"typeVersion": 4.2
},
{
"id": "0d4d3bab-2370-4ced-8f5d-2977d360f72b",
"name": "获取文件夹",
"type": "n8n-nodes-base.googleDrive",
"position": [
120,
220
],
"parameters": {
"filter": {
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1RO5ByPhq2yvYLmbapTNC_kKdU5lZd4W5",
"cachedResultUrl": "https://drive.google.com/drive/folders/1RO5ByPhq2yvYLmbapTNC_kKdU5lZd4W5",
"cachedResultName": "Test Negozio"
}
},
"options": {},
"resource": "fileFolder"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "HEy5EuZkgPZVEa9w",
"name": "Google Drive account (n3w.it)"
}
},
"typeVersion": 3
},
{
"id": "e81ee92f-db50-4c62-aac7-7bc03e63cc1a",
"name": "获取文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
700,
240
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {
"googleFileConversion": {
"conversion": {
"docsToFormat": "text/plain"
}
}
},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "HEy5EuZkgPZVEa9w",
"name": "Google Drive account (n3w.it)"
}
},
"typeVersion": 3
},
{
"id": "c9bdc00a-ca8c-4457-8720-e6dce07e6b22",
"name": "聊天输入",
"type": "n8n-nodes-base.set",
"position": [
-200,
1080
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "282b9bed-e5fd-4edb-95d5-682bcc08e070",
"name": "chatInput",
"type": "string",
"value": "={{ $json.chatInput }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "b65ca747-e738-4b7a-ae02-83840ce0a460",
"name": "检索来源",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
140,
940
],
"parameters": {
"mode": "load",
"topK": 5,
"prompt": "={{ $json.chatInput }}",
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "negozio-emporio-verde",
"cachedResultName": "negozio-emporio-verde"
}
},
"credentials": {
"qdrantApi": {
"id": "iyQ6MQiVaF3VMBmt",
"name": "QdrantApi account (Hetzner)"
}
},
"typeVersion": 1.1
},
{
"id": "265e2613-0155-4585-8d5c-fcda26975585",
"name": "输出",
"type": "n8n-nodes-base.set",
"position": [
1060,
1140
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b296c92b-d9ee-4322-b972-d1069d01feb8",
"name": "output",
"type": "string",
"value": "={{ $('Question and Answer Chain').item.json.response }}\n\nSources: {{ (JSON.stringify($json.unique_file_names)) }},"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "9407fcaf-d90a-46bd-9b1f-b0493a0357c1",
"name": "回复",
"type": "n8n-nodes-base.code",
"position": [
880,
1140
],
"parameters": {
"jsCode": "const item = $input.item.json;\n\n// Creiamo Set per rimuovere duplicati\nconst uniqueFileIds = Array.from(new Set(item.file_id));\nconst uniqueFileNames = Array.from(new Set(item.file_name));\n\n// Ritorniamo un item con i valori univoci\nreturn [\n {\n json: {\n unique_file_ids: uniqueFileIds,\n unique_file_names: uniqueFileNames\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "0b8a715f-36eb-49fd-895e-e8e76fdbb0c1",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-360,
-520
],
"parameters": {
"width": 840,
"height": 220,
"content": "## 使用 Qdrant 的完整 RAG 系统,带自动来源引用"
},
"typeVersion": 1
},
{
"id": "3220c323-a3d6-4855-ad05-2aaf8761771e",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-200
],
"parameters": {
"color": 6,
"width": 880,
"height": 220,
"content": "# 步骤 1"
},
"typeVersion": 1
},
{
"id": "738835a3-888b-426e-a897-8ddc630b85bf",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-220,
120
],
"parameters": {
"color": 4,
"width": 620,
"height": 520,
"content": "# 步骤 2"
},
"typeVersion": 1
},
{
"id": "70205511-2c4a-4f2f-8f68-97e3ede28851",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
1200,
620
],
"parameters": {
"color": 4,
"width": 520,
"height": 420,
"content": "设置为元数据:"
},
"typeVersion": 1
},
{
"id": "921497ff-1beb-4bd1-aecd-81b68c5a0357",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
1400
],
"parameters": {
"color": 3,
"width": 520,
"height": 200,
"content": "最终输出为:"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "33d05a21-33dd-422a-ba58-3eafffc7d50a",
"connections": {
"Wait": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Response",
"type": "main",
"index": 0
}
]
]
},
"Get file": {
"main": [
[
{
"node": "Qdrant Vector Store",
"type": "main",
"index": 0
}
]
]
},
"Response": {
"main": [
[
{
"node": "Output",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"chatInput": {
"main": [
[
{
"node": "Question and Answer Chain",
"type": "main",
"index": 0
},
{
"node": "Retrive sources",
"type": "main",
"index": 0
}
]
]
},
"Get folder": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Get file",
"type": "main",
"index": 0
}
]
]
},
"Retrive sources": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Clear collection": {
"main": [
[
{
"node": "Get folder",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Qdrant Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Qdrant Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Embeddings OpenAI4": {
"ai_embedding": [
[
{
"node": "Retrive sources",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Qdrant Vector Store": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Default Data Loader1": {
"ai_document": [
[
{
"node": "Qdrant Vector Store",
"type": "ai_document",
"index": 0
}
]
]
},
"Qdrant Vector Store1": {
"ai_vectorStore": [
[
{
"node": "Vector Store Retriever",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"Vector Store Retriever": {
"ai_retriever": [
[
{
"node": "Question and Answer Chain",
"type": "ai_retriever",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Question and Answer Chain",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Question and Answer Chain": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "chatInput",
"type": "main",
"index": 0
}
]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader1",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"When clicking ‘Test workflow’": {
"main": [
[
{
"node": "Clear collection",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 人工智能, IT 运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于 Mistral OCR 的完整 RAG 从 PDF 开始
使用Mistral OCR、Qdrant和Gemini AI构建PDF文档RAG系统
Set
Code
Wait
+16
34 节点Davide
人工智能
启用RAG中文档的更新功能
使用Google Drive、Qdrant和Gemini Chat构建和更新RAG系统
Set
Wait
Google Drive
+12
29 节点Davide
人工智能
使用 Qdrant 的完整 RAG 系统,带自动更新文档功能
使用OpenAI、Google Gemini、Qdrant和Google Drive构建自更新RAG系统
Set
Wait
Google Drive
+13
32 节点Davide
AI RAG 检索增强
AI智能助手:与Supabase存储和Google Drive文件对话
AI智能助手:与Supabase存储和Google Drive文件对话
If
Set
Wait
+20
62 节点Mark Shcherbakov
工程
AI驱动的Telegram助手终极入门指南(PDF、Brave搜索和Google套件)
使用Gemini、RAG PDF搜索和Google套件构建多功能Telegram机器人
Set
Code
Wait
+26
79 节点Issam AGGOUR
人工智能
生成考试题目
基于Google文档和Gemini的AI驱动自动生成考试题目与答案
Code
Google Docs
Http Request
+17
37 节点Davide
其他
工作流信息
难度等级
高级
节点数量29
分类2
节点类型18
作者
Davide
@n3witaliaFull-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at info@n3w.it or add me on Linkedin.com/in/davideboizza
外部链接
在 n8n.io 查看 →
分享此工作流