基于Weaviate和OpenAI的RAG文档问答
高级
这是一个Document Extraction、Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 Set、FormTrigger、ExtractFromFile、ChatTrigger、LmChatOpenAi 等节点。 基于RAG的文档问答:使用Weaviate和OpenAI查询PDF内容
前置要求
- •OpenAI API Key
使用的节点 (17 个)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "hWxVTNvDEcGofp5O",
"meta": {
"instanceId": "be3e0177f1eeda5879f300082f54531dfa9819a5d7441e94ea64b32f8b1fd49c",
"templateCredsSetupCompleted": true
},
"name": "rag-with-weaviate",
"tags": [],
"nodes": [
{
"id": "4cfa559c-9cec-4a74-84d5-9cf4a2d7915a",
"name": "Weaviate 向量存储",
"type": "@n8n/n8n-nodes-langchain.vectorStoreWeaviate",
"position": [
432,
288
],
"parameters": {
"mode": "insert",
"options": {
"textKey": "text"
},
"weaviateCollection": {
"__rl": true,
"mode": "id",
"value": "FileUpload"
}
},
"credentials": {
"weaviateApi": {
"id": "qiTSL6FfsPCZLyUv",
"name": "Weaviate Credentials account"
}
},
"typeVersion": 1.2
},
{
"id": "c87c8fe2-56bf-405f-a91a-3b1af7cf2e8c",
"name": "默认数据加载器",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
512,
496
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{}
]
}
},
"jsonData": "={{ $json.text }}",
"jsonMode": "expressionData"
},
"typeVersion": 1
},
{
"id": "ac0c796a-3b1d-4ba6-83e5-23a673e4628d",
"name": "OpenAI 嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
384,
496
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "v6dOwJXW6XXHxHQw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "d89bd8be-a275-4a57-a1a6-6006302ba3dd",
"name": "递归字符文本分割器1",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
544,
656
],
"parameters": {
"options": {},
"chunkSize": 500
},
"typeVersion": 1
},
{
"id": "dcabfdff-749b-4442-933d-409b1479d2c8",
"name": "从文件提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
-48,
288
],
"parameters": {
"options": {
"maxPages": 99
},
"operation": "pdf",
"binaryPropertyName": "PDF_File"
},
"typeVersion": 1
},
{
"id": "779add5c-4770-472a-a2e9-934e1e2e4569",
"name": "编辑字段",
"type": "n8n-nodes-base.set",
"position": [
128,
288
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "d719d94d-6597-402c-8958-dd270de82ce6",
"name": "text",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "eda536c5-d88f-45e4-9505-d3b1e6c5fa27",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
992,
288
],
"webhookId": "683bf7e6-5f6f-43e0-afef-eb854d52ebed",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "94ed5f2b-fb86-42e8-a778-ab51d7a49d42",
"name": "Weaviate 向量存储1",
"type": "@n8n/n8n-nodes-langchain.vectorStoreWeaviate",
"position": [
1280,
624
],
"parameters": {
"options": {},
"weaviateCollection": {
"__rl": true,
"mode": "list",
"value": "FileUpload",
"cachedResultName": "FileUpload"
}
},
"credentials": {
"weaviateApi": {
"id": "qiTSL6FfsPCZLyUv",
"name": "Weaviate Credentials account"
}
},
"typeVersion": 1.3
},
{
"id": "ae3a9b66-a5c8-4108-980c-1c3ace05e528",
"name": "问答链",
"type": "@n8n/n8n-nodes-langchain.chainRetrievalQa",
"position": [
1168,
288
],
"parameters": {
"text": "=Using only the attached Weaviate vector store collection (and no external knowledge), answer the following query:\n{{ $json.chatInput }}",
"options": {},
"promptType": "define"
},
"typeVersion": 1.6
},
{
"id": "d9110fef-f3ae-4c3a-bfc0-b3bfe0f6fcb0",
"name": "向量存储检索器",
"type": "@n8n/n8n-nodes-langchain.retrieverVectorStore",
"position": [
1280,
480
],
"parameters": {},
"typeVersion": 1
},
{
"id": "79aaa15c-f0d6-4c88-bd15-ff7835131b2b",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1152,
480
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "v6dOwJXW6XXHxHQw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "9f961ef2-5466-475d-9ccb-1436469dee00",
"name": "OpenAI 嵌入1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
1360,
768
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "v6dOwJXW6XXHxHQw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "d46d3a49-ec16-40aa-928e-291fc90b9f2d",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-256,
176
],
"parameters": {
"color": 5,
"width": 544,
"height": 336,
"content": "## 第 1 部分:手动上传数据"
},
"typeVersion": 1
},
{
"id": "9b192882-6d54-43c5-9ccb-cca0bcf456f4",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
944,
176
],
"parameters": {
"color": 6,
"width": 640,
"height": 736,
"content": "## 第 3 部分:使用 Weaviate 对 PDF 文件执行 RAG"
},
"typeVersion": 1
},
{
"id": "431f55e3-9599-4de7-a363-2e82e6581101",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-256,
-128
],
"parameters": {
"color": 4,
"width": 992,
"height": 288,
"content": "# 使用 Weaviate 对 PDF 文件进行 RAG"
},
"typeVersion": 1
},
{
"id": "588d9eee-f769-4c6b-9b16-2b1790118a4d",
"name": "上传 PDF",
"type": "n8n-nodes-base.formTrigger",
"position": [
-224,
288
],
"webhookId": "8499e732-aff6-4e0f-85ac-4c0591012616",
"parameters": {
"options": {},
"formTitle": "Upload your file here",
"formFields": {
"values": [
{
"fieldType": "file",
"fieldLabel": "PDF File",
"multipleFiles": false,
"requiredField": true,
"acceptFileTypes": ".pdf"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "4d4244ef-c4af-4eb1-8389-6bd95cc5613e",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
304,
176
],
"parameters": {
"color": 3,
"width": 624,
"height": 688,
"content": "## 第 2 部分:嵌入数据并加载到 Weaviate 集合中"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "61bb6430-21b1-4443-8924-34a83eab6965",
"connections": {
"Upload PDF": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Weaviate Vector Store",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Weaviate Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Question and Answer Chain",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Weaviate Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Weaviate Vector Store",
"type": "ai_document",
"index": 0
}
]
]
},
"Weaviate Vector Store": {
"main": [
[]
]
},
"Vector Store Retriever": {
"ai_retriever": [
[
{
"node": "Question and Answer Chain",
"type": "ai_retriever",
"index": 0
}
]
]
},
"Weaviate Vector Store1": {
"ai_vectorStore": [
[
{
"node": "Vector Store Retriever",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Question and Answer Chain",
"type": "main",
"index": 0
}
]
]
},
"Recursive Character Text Splitter1": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于Document Extraction、Multimodal AI等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于AI的WhatsApp支持机器人(Google Sheets工单创建)
基于AI的WhatsApp支持机器人(Google Sheets工单创建)
Set
Xml
Code
+20
35 节点Zain Khan
Support Chatbot
使用 Google Drive 的 RAG 聊天机器人
使用OpenAI、Google Drive和Supabase构建RAG知识聊天机器人
Set
Supabase
Google Drive
+12
20 节点Babish Shrestha
Miscellaneous
使用 Qdrant 的完整 RAG 系统,带自动更新文档功能
使用OpenAI、Google Gemini、Qdrant和Google Drive构建自更新RAG系统
Set
Wait
Google Drive
+13
32 节点Davide
AI RAG
AI趋势邮件提醒器-weaviate
构建基于arXiv和Weaviate的每周AI趋势提醒器
Set
Xml
Merge
+18
48 节点Mary Newhauser
Content Creation
上下文混合RAG AI文案
Google Drive到Supabase上下文向量数据库同步用于RAG应用
If
Set
Code
+25
76 节点Michael Taleb
AI RAG
PDF 转向量 RAG 系统:Mistral OCR、Weaviate 数据库和 MCP 服务器
使用Mistral OCR和Weaviate数据库构建PDF搜索系统
Set
Mistral Ai
Form Trigger
+7
13 节点Dietmar
Document Extraction