文档 RAG 和聊天代理:Google Drive 到 Qdrant 与 Mistral OCR
高级
这是一个Internal Wiki、AI RAG领域的自动化工作流,包含 40 个节点。主要使用 If、Set、Code、GoogleDrive、HttpRequest 等节点。 文档 RAG 和聊天代理:Google Drive 到 Qdrant 与 Mistral OCR
前置要求
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
- •Qdrant 服务器连接信息
使用的节点 (40 个)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "e4680277d6b9c8b80748f71c2c1d0f9a640576175738ea2675967f762eeaf9df",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "7935a827-516b-4e64-b370-f17d23c70857",
"name": "OpenAI 嵌入1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
1488,
432
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"id": "BEMsaCWtnyqTUtIt",
"name": "OpenAi account 8 dbt digi"
}
},
"typeVersion": 1.2
},
{
"id": "32429618-1bed-4134-953f-fa5f0eed6981",
"name": "OpenAI 聊天模型1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
528,
432
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "gpt-4.1-mini"
},
"options": {
"temperature": 0.5
}
},
"credentials": {
"openAiApi": {
"id": "BEMsaCWtnyqTUtIt",
"name": "OpenAi account 8 dbt digi"
}
},
"typeVersion": 1.2
},
{
"id": "c770feb0-c01a-4e94-832a-3dafc88fb28f",
"name": "网络搜索",
"type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
"position": [
1200,
480
],
"parameters": {
"url": "https://api.tavily.com/search",
"method": "POST",
"jsonBody": "={\n \"query\": \"{query}\",\n \"topic\": \"general\",\n \"search_depth\": \"advanced\",\n \"max_results\": 20,\n \"include_answer\": true,\n \"include_raw_content\": false,\n \"include_images\": false,\n \"include_image_descriptions\": false,\n \"include_domains\": [],\n \"exclude_domains\": [\"\"]\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"toolDescription": "Web Search tool ",
"optimizeResponse": true,
"parametersHeaders": {
"values": [
{
"name": "Authorization",
"value": "add tavily token",
"valueProvider": "fieldValue"
},
{
"name": "Content-Type",
"value": "application/json",
"valueProvider": "fieldValue"
}
]
},
"placeholderDefinitions": {
"values": [
{
"name": "query",
"type": "string",
"description": "Search Querry"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "5b31d3c8-3fe5-4cfd-bb09-81193e6d973f",
"name": "简单记忆1",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
688,
432
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "42ff3014-5b83-474f-a35c-5384828b49fd",
"name": "Qdrant 向量存储",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
1488,
304
],
"parameters": {
"mode": "retrieve-as-tool",
"topK": 3,
"options": {},
"toolName": "add_name",
"toolDescription": "Use RAG to look up information in the knowledgebase.",
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "docaiauto",
"cachedResultName": "docaiauto"
}
},
"credentials": {
"qdrantApi": {
"id": "4NinNhNX7VxfgZxs",
"name": "QdrantApi account 2"
}
},
"typeVersion": 1.1
},
{
"id": "c405636b-4957-4de1-9cd4-8733647af3a9",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
496,
112
],
"webhookId": "9c27865f-526c-490f-80a2-645bc919e9de",
"parameters": {
"public": true,
"options": {}
},
"typeVersion": 1.1
},
{
"id": "8f2950f4-0c96-4d70-9aa0-2729dd0b560e",
"name": "默认数据加载器",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
3344,
1328
],
"parameters": {
"options": {
"metadata": {
"metadataValues": [
{
"name": "source",
"value": "={{ $('set all metadata').item.json[\"Document name\"] }}"
},
{
"name": "blobType",
"value": "application/jsonb"
},
{
"name": "loc",
"value": "={{ $('Mistral DOC OCR').item.json.usage_info }}"
},
{
"name": "source_metadata_id",
"value": "={{ $('Google Drive1').item.json.file_url }}"
},
{
"name": "department",
"value": "ai_automation"
},
{
"name": "PROJECT",
"value": "={{ $('set all metadata').item.json.PROJECT }}"
},
{
"name": "=DOCUMNENT_TYPE",
"value": "={{ $('set all metadata').item.json.DOCUMENT_TYPE }}"
},
{
"name": "ASSIGNED_TO",
"value": "={{ $('set all metadata').item.json.ASSIGNEDTO }}"
}
]
}
},
"jsonData": "={{ $json.content }}",
"jsonMode": "expressionData"
},
"typeVersion": 1
},
{
"id": "b008bae1-bc63-47da-8afa-b8a1b17ea412",
"name": "字符文本分割器",
"type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
"position": [
3408,
1440
],
"parameters": {},
"typeVersion": 1
},
{
"id": "fb42d3ab-5c20-4efc-920a-87dc96890cab",
"name": "Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
368,
1136
],
"parameters": {
"filter": {
"folderId": {
"__rl": true,
"mode": "list",
"value": "1C1zD1XefBltEAocX6kfHFbzQtzzAxo_E",
"cachedResultUrl": "https://drive.google.com/drive/folders/1C1zD1XefBltEAocX6kfHFbzQtzzAxo_E",
"cachedResultName": "knowledgebaseforaibot"
}
},
"options": {
"fields": [
"id",
"name",
"webViewLink",
"mimeType",
"*"
]
},
"resource": "fileFolder",
"searchMethod": "query"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "xS6kSuLaEkasxHtm",
"name": "Google Drive account 6 rn dbt"
}
},
"typeVersion": 3
},
{
"id": "393465a4-4b14-42ef-b2ca-608a161c6914",
"name": "Google Drive1",
"type": "n8n-nodes-base.googleDrive",
"position": [
1088,
1152
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "url",
"value": "={{ $('add metadata').item.json.file_url }}"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "xS6kSuLaEkasxHtm",
"name": "Google Drive account 6 rn dbt"
}
},
"typeVersion": 3
},
{
"id": "3e38082e-4619-47cf-98e0-f7f66a8541c1",
"name": "Mistral 上传",
"type": "n8n-nodes-base.httpRequest",
"position": [
1328,
1152
],
"parameters": {
"url": "https://api.mistral.ai/v1/files",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "multipart-form-data",
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "purpose",
"value": "ocr"
},
{
"name": "file",
"parameterType": "formBinaryData",
"inputDataFieldName": "data"
}
]
},
"nodeCredentialType": "mistralCloudApi"
},
"credentials": {
"mistralCloudApi": {
"id": "k9FknrnRcIKYNX7T",
"name": "Mistral Cloud account 2 dbt rn"
}
},
"typeVersion": 4.2
},
{
"id": "255683ca-712a-4386-ae19-b3fbb5f37e30",
"name": "Mistral 签名 URL",
"type": "n8n-nodes-base.httpRequest",
"position": [
1552,
1152
],
"parameters": {
"url": "=https://api.mistral.ai/v1/files/{{ $json.id }}/url",
"options": {},
"sendQuery": true,
"sendHeaders": true,
"authentication": "predefinedCredentialType",
"queryParameters": {
"parameters": [
{
"name": "expiry",
"value": "24"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Accept",
"value": "application/json"
}
]
},
"nodeCredentialType": "mistralCloudApi"
},
"credentials": {
"mistralCloudApi": {
"id": "k9FknrnRcIKYNX7T",
"name": "Mistral Cloud account 2 dbt rn"
}
},
"typeVersion": 4.2
},
{
"id": "2e846e38-ae17-4717-a39b-b3d0e0c567f9",
"name": "Mistral 文档 OCR",
"type": "n8n-nodes-base.httpRequest",
"position": [
1776,
1152
],
"parameters": {
"url": "https://api.mistral.ai/v1/ocr",
"method": "POST",
"options": {},
"jsonBody": "={\n \"model\": \"mistral-ocr-latest\",\n \"document\": {\n \"type\": \"document_url\",\n \"document_url\": \"{{ $json.url }}\"\n },\n \"include_image_base64\": true\n}",
"sendBody": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "mistralCloudApi"
},
"credentials": {
"mistralCloudApi": {
"id": "k9FknrnRcIKYNX7T",
"name": "Mistral Cloud account 2 dbt rn"
}
},
"typeVersion": 4.2
},
{
"id": "a1c139ec-5ec2-4142-aacc-5df387b677fd",
"name": "当点击\"测试工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
96,
1136
],
"parameters": {},
"typeVersion": 1
},
{
"id": "6ceb4cbc-b4b0-4ac6-befe-a92649279bf4",
"name": "OpenAI 嵌入",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
3168,
1456
],
"parameters": {
"model": "text-embedding-3-small",
"options": {}
},
"credentials": {
"openAiApi": {
"id": "BEMsaCWtnyqTUtIt",
"name": "OpenAi account 8 dbt digi"
}
},
"typeVersion": 1
},
{
"id": "ee2ce006-d94c-49a7-849f-8155c95ee118",
"name": "Qdrant 向量存储1",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"position": [
3184,
1152
],
"parameters": {
"mode": "insert",
"options": {},
"qdrantCollection": {
"__rl": true,
"mode": "list",
"value": "docaiauto",
"cachedResultName": "docaiauto"
},
"embeddingBatchSize": "=200"
},
"credentials": {
"qdrantApi": {
"id": "hBirQvCk1VaV8cfQ",
"name": "QdrantApi account"
}
},
"typeVersion": 1.1
},
{
"id": "b4a1a6a6-6f2e-4ac6-8fba-f5752ac66259",
"name": "Mistral Cloud 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
"position": [
2208,
1456
],
"parameters": {
"model": "mistral-small-latest",
"options": {}
},
"credentials": {
"mistralCloudApi": {
"id": "k9FknrnRcIKYNX7T",
"name": "Mistral Cloud account 2 dbt rn"
}
},
"typeVersion": 1
},
{
"id": "85a90fcf-b75c-4ecc-90e2-611c8db61073",
"name": "AI 聊天代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
992,
112
],
"parameters": {
"options": {
"systemMessage": "=You are a helpful, intelligent AI Knowledge Bot and proactive chat agent. \nLead conversations by asking open-ended questions and offering suggestions. \nAnticipate needs, follow up thoughtfully, and make the user feel supported throughout.\n\n---\n\n## **Knowledge Access Workflow**\n\n1. **Primary Source: qdrant vector store (`add_table_name` table)** \n - For **every** user query, first search **only** in qdrant. \n - If relevant information is found:\n - Respond in a **clear, structured, and informative** manner. \n - **Always include multiple images** if available — aim for **maximum number of relevant images**, not just one. \n - Place each image **inline**, immediately after the sentence/section it illustrates. \n - Never group all images at the end.\n - Always **cite the internal document name** and **provide a clickable URL** to the source document.\n - Use `list doc` tool with `source_metadata_id` to retrieve the document URL.\n \n **Example Citation:** \n > This information is based on the internal AI documentation related to automation projects (Automation Timesheet Blogs). \n > [View Full Document](document_url_here)\n\n2. **If No Match Found:** \n - Reply: \n `\"The information you requested is not available in our internal documentation. Would you like me to do a Web search?\"`\n\n3. **Web Search Rules:** \n - Only search if user explicitly agrees (e.g., \"Yes\", \"Okay\"). \n - use 'web search 1'tool\n - Clearly label as **External Source** and provide clickable URLs. \n Example: \n > This information comes from an external source ([website_name](source_url)).\n\n4. **If No Data in Qdrant or Web:** \n - Reply: \n `\"At the moment, there is no information available to fully address this request based on current internal and external sources.\"`\n\n---\n\n## **Formatting & Style**\n- **Language:** All qdrant queries in English; all responses in English. \n- **Tone:** Professional, clear, structured, and helpful. \n- **Image Usage:** \n - Always include **all available relevant images** MARKDOWN — even if it means showing several per section. \n - Place images **exactly after the point they illustrate**. \n - Use different images for different subtopics, comparisons, or examples. \n - Do **not** skip images if they exist in the source.\n- **For Guide/Instruction Responses:** \n 1. **Step-by-Step Guide** (detailed instructions) \n 2. **Things to Consider** (common pitfalls, important details) \n 3. **Further Understanding** \n - Suggest 2 related topics the user might explore next, relevant to their query.\n- Never skip key details. Always check if more images can be added to improve clarity.\n\n---\n\n## **Core Principles**\n- Be proactive — never wait for the user to guide the entire conversation. \n- Ask open-ended follow-ups. \n- Anticipate related needs based on the query. \n- Maintain accuracy, cite sources, and **use as many relevant images as possible**. \n- ALWAYS SHOW IMAGE AND Keep images inline and contextually placed.\n",
"returnIntermediateSteps": false
}
},
"typeVersion": 1.7
},
{
"id": "3e71d64a-3a04-4f5e-b009-8eddbef94e8c",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
1008,
416
],
"parameters": {
"color": 5,
"width": 400,
"height": 208,
"content": "## 使用 tavily 进行网络搜索 (http 节点)"
},
"typeVersion": 1
},
{
"id": "3c335f41-3d05-4436-ad0f-ce6957967a0c",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
928
],
"parameters": {
"color": 5,
"width": 224,
"height": 400,
"content": "## 从选定的 Google Drive 文件夹获取所有文件数据"
},
"typeVersion": 1
},
{
"id": "a404df40-0f40-46b5-a65b-edc182d06d9b",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1936,
1040
],
"parameters": {
"color": 5,
"width": 192,
"height": 256,
"content": "## 移除空数据字段"
},
"typeVersion": 1
},
{
"id": "4776e7ea-7243-474f-9ec0-47afc46d8479",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1024,
976
],
"parameters": {
"color": 5,
"width": 208,
"height": 320,
"content": "## 从选定的 Google Drive 获取单个文件"
},
"typeVersion": 1
},
{
"id": "3a593a87-2d91-48dc-85da-98a5bc562ff6",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1280,
1008
],
"parameters": {
"color": 5,
"width": 608,
"height": 272,
"content": "## MISTRAL OCR"
},
"typeVersion": 1
},
{
"id": "65106e47-a303-4f46-be3b-207d6e6c04fa",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
352,
16
],
"parameters": {
"color": 5,
"width": 368,
"height": 288,
"content": "## 托管聊天界面"
},
"typeVersion": 1
},
{
"id": "78103cfe-e101-4d70-8dea-08b4ca2bbdb6",
"name": "### 需要帮助?",
"type": "n8n-nodes-base.stickyNote",
"position": [
1472,
96
],
"parameters": {
"color": 5,
"width": 272,
"height": 496,
"content": "## QDRANT 向量和 OPEN API 嵌入"
},
"typeVersion": 1
},
{
"id": "716859d0-f3eb-431c-a6fc-37301508c968",
"name": "## 试试看!",
"type": "n8n-nodes-base.stickyNote",
"position": [
928,
0
],
"parameters": {
"color": 5,
"width": 432,
"height": 304,
"content": "## AI 聊天代理"
},
"typeVersion": 1
},
{
"id": "aa7c86ee-3229-415e-96eb-92fbd530aa44",
"name": "便签10",
"type": "n8n-nodes-base.stickyNote",
"position": [
2672,
1008
],
"parameters": {
"color": 5,
"width": 320,
"height": 288,
"content": "## 清理所有提取的数据并将其转换为较小的块"
},
"typeVersion": 1
},
{
"id": "ccd381e0-1cd2-406d-9aec-7b03c18ee435",
"name": "便签 11",
"type": "n8n-nodes-base.stickyNote",
"position": [
2176,
928
],
"parameters": {
"color": 5,
"width": 288,
"height": 368,
"content": "## 分配代理"
},
"typeVersion": 1
},
{
"id": "87f7a493-d65c-447b-a465-3175c1bcbea7",
"name": "便签 12",
"type": "n8n-nodes-base.stickyNote",
"position": [
3088,
976
],
"parameters": {
"color": 5,
"width": 512,
"height": 608,
"content": "## 将所有块加载到 qdrant 向量数据库中"
},
"typeVersion": 1
},
{
"id": "66f3dfcf-9fbe-4d63-888e-dda7c422c282",
"name": "## 1. 创建新的自定义 OpenAI 凭据",
"type": "n8n-nodes-base.stickyNote",
"position": [
576,
992
],
"parameters": {
"color": 5,
"width": 256,
"height": 320,
"content": "## 遍历 Google Drive 文件夹项"
},
"typeVersion": 1
},
{
"id": "d21fe18b-7f9b-46b5-a8b5-2725c849db7f",
"name": "遍历 Google Drive 文件夹中的每个文件",
"type": "n8n-nodes-base.splitInBatches",
"position": [
608,
1136
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "4300ad47-a92a-408b-aa8b-b56249d341e9",
"name": "添加元数据",
"type": "n8n-nodes-base.set",
"position": [
896,
1152
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "10646eae-ae46-4327-a4dc-9987c2d76173",
"name": "file_id",
"type": "string",
"value": "={{ $json.id }}"
},
{
"id": "f4536df5-d0b1-4392-bf17-b8137fb31a44",
"name": "file_type",
"type": "string",
"value": "={{ $json.mimeType }}"
},
{
"id": "77d782de-169d-4a46-8a8e-a3831c04d90f",
"name": "file_title",
"type": "string",
"value": "={{ $json.name }}"
},
{
"id": "9bde4d7f-e4f3-4ebd-9338-dce1350f9eab",
"name": "file_url",
"type": "string",
"value": "={{ $json.webViewLink }}"
},
{
"id": "fae402c8-c486-4b57-8d28-bf669db6b442",
"name": "last_modified_date",
"type": "string",
"value": "={{ $json.modifiedTime }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "efc3f354-0a6d-46dc-8ecf-793873e19466",
"name": "If 节点",
"type": "n8n-nodes-base.if",
"position": [
1984,
1152
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "d15e917b-43d2-40b8-8b49-af467ff63961",
"operator": {
"type": "string",
"operation": "notExists",
"singleValue": true
},
"leftValue": "={{ $json.data[0].parseJson().skipped }}",
"rightValue": ""
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
},
{
"id": "33e574c3-47a2-454b-85e9-e3e9983e3d63",
"name": "基于文件名分配不同的元数据",
"type": "@n8n/n8n-nodes-langchain.informationExtractor",
"position": [
2208,
1152
],
"parameters": {
"text": "=\n{{ $json.pages[0].markdown }}",
"options": {
"systemPromptTemplate": "You are an expert extraction algorithm.\nOnly extract relevant information from the text.\ngive data is "
},
"attributes": {
"attributes": [
{
"name": "document_type",
"description": "type of document this can be blog, user documentation, technical documentation, manual/guide, educational"
},
{
"name": "project",
"description": " from give project this can any one ,social/digimarketing , chatbot, knowledge bot if nothing that its default"
},
{
"name": "assigned_to",
"description": "who are handling give projects mention all name given for a give project\n\nif project LINKED/DIGIMARRKETING/SOCIAL = [employee name]\nif project KB BOT = [employee name]\nif project CHAT BOT = [employee name]\nif project TIMESHEET = [employee name]"
}
]
}
},
"typeVersion": 1
},
{
"id": "c4b2a5cb-b849-4d7e-9f24-7ef67ee4031a",
"name": "设置所有元数据",
"type": "n8n-nodes-base.set",
"position": [
2512,
1152
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5132d92c-41da-4a55-ad79-0c329ca7e626",
"name": "Document name",
"type": "string",
"value": "={{ $('Google Drive1').item.json.file_title }}"
},
{
"id": "c8160701-2be7-43c6-bcfa-295fbebe0e23",
"name": "Document data",
"type": "string",
"value": "={{ $('If NODE').item.json.pages[0].markdown }}"
},
{
"id": "1087ab34-5643-4755-b545-cf34d0ae2cd2",
"name": " source",
"type": "string",
"value": "={{ $('Google Drive1').item.json.file_id }}"
},
{
"id": "4317aa31-d9fd-4adc-ab26-b48c208041b3",
"name": "ASSIGNEDTO",
"type": "string",
"value": "={{ $json.output.assigned_to.split(\",\") }}"
},
{
"id": "7a61d775-06b1-42e2-a82a-d8e756fa5586",
"name": "PROJECT",
"type": "string",
"value": "={{ $json.output.project }}"
},
{
"id": "300f49d6-8851-458d-a296-8ceb68ebdd5f",
"name": "DOCUMENT_TYPE",
"type": "string",
"value": "={{ $json.output.document_type }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "2a4026cf-3034-49a8-8dc8-ad67ae571213",
"name": "清理输出",
"type": "n8n-nodes-base.code",
"position": [
2704,
1152
],
"parameters": {
"jsCode": "// Get incoming data (first item)\nconst data = items[0].json;\n\n// If wrapped in an array, unwrap it\nconst input = Array.isArray(data) ? data[0] : data;\n\nlet output = [\n {\n content: input[\"Document data\"], // main text for embedding\n metadata: {\n document_name: input[\"Document name\"],\n source_id: input[\" source\"], // note: there is a space before \"source\" in your key\n }\n }\n];\n\nreturn output.map(o => ({ json: o }));\n"
},
"typeVersion": 2
},
{
"id": "f9172d1d-060c-46f7-8e48-b235a2610185",
"name": "将数据转换为较小的块",
"type": "n8n-nodes-base.code",
"position": [
2864,
1152
],
"parameters": {
"jsCode": "const chunkSize = 1000; // characters\nconst chunkOverlap = 100; // characters\n\n\nlet newItems = [];\n\nfor (const item of items) {\n let text = item.json.content; // <-- use item.json\n if (!text || typeof text !== \"string\") continue;\n\n const sourceId = item.json.metadata.source_id;\n\n \n // Chunking\n for (let i = 0; i < updatedText.length; i += chunkSize - chunkOverlap) {\n let chunk = updatedText.slice(i, i + chunkSize);\n newItems.push({\n json: {\n content: chunk,\n metadata: item.json.metadata\n }\n });\n }\n}\n\nreturn newItems;\n"
},
"typeVersion": 2
},
{
"id": "2a9539e7-e8dc-4c2a-a016-daab8c7d5339",
"name": "GET 模型",
"type": "n8n-nodes-base.stickyNote",
"position": [
3696,
736
],
"parameters": {
"color": 5,
"width": 800,
"height": 1248,
"content": "### **节点列表和描述**"
},
"typeVersion": 1
},
{
"id": "1dc0d13d-c75c-44dd-a94c-0b177cf6c094",
"name": "便签13",
"type": "n8n-nodes-base.stickyNote",
"position": [
1808,
-320
],
"parameters": {
"color": 5,
"width": 960,
"height": 928,
"content": "### **节点列表和描述**"
},
"typeVersion": 1
},
{
"id": "83726285-3bfd-4d22-ad35-39a5ff3ef414",
"name": "便签14",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1232,
-176
],
"parameters": {
"color": 5,
"width": 864,
"height": 1856,
"content": "# 知识 RAG 和 AI 聊天代理"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"If NODE": {
"main": [
[
{
"node": "based file name it assign differ metadata",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over each file in gdrive folder",
"type": "main",
"index": 0
}
]
]
},
"Web Search ": {
"ai_tool": [
[
{
"node": "ai chat agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Google Drive": {
"main": [
[
{
"node": "Loop Over each file in gdrive folder",
"type": "main",
"index": 0
}
]
]
},
"add metadata": {
"main": [
[
{
"node": "Google Drive1",
"type": "main",
"index": 0
}
]
]
},
"clean output": {
"main": [
[
{
"node": "convert data into smaller chunks",
"type": "main",
"index": 0
}
]
]
},
"Google Drive1": {
"main": [
[
{
"node": "Mistral Upload",
"type": "main",
"index": 0
}
]
]
},
"Mistral Upload": {
"main": [
[
{
"node": "Mistral Signed URL",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory1": {
"ai_memory": [
[
{
"node": "ai chat agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Mistral DOC OCR": {
"main": [
[
{
"node": "If NODE",
"type": "main",
"index": 0
}
]
]
},
"set all metadata": {
"main": [
[
{
"node": "clean output",
"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
}
]
]
},
"Mistral Signed URL": {
"main": [
[
{
"node": "Mistral DOC OCR",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "ai chat agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Qdrant Vector Store1",
"type": "ai_document",
"index": 0
}
]
]
},
"Qdrant Vector Store": {
"ai_tool": [
[
{
"node": "ai chat agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Qdrant Vector Store1": {
"main": [
[
{
"node": "Loop Over each file in gdrive folder",
"type": "main",
"index": 0
}
]
]
},
"Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"Mistral Cloud Chat Model": {
"ai_languageModel": [
[
{
"node": "based file name it assign differ metadata",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "ai chat agent",
"type": "main",
"index": 0
}
]
]
},
"convert data into smaller chunks": {
"main": [
[
{
"node": "Qdrant Vector Store1",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Test workflow’": {
"main": [
[
{
"node": "Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Loop Over each file in gdrive folder": {
"main": [
[],
[
{
"node": "add metadata",
"type": "main",
"index": 0
}
]
]
},
"based file name it assign differ metadata": {
"main": [
[
{
"node": "set all metadata",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于Internal Wiki、AI RAG等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于Google Drive知识库的网站聊天机器人(GPT-4与Mistral AI)
基于Google Drive知识库的网站聊天机器人(GPT-4与Mistral AI)
If
Set
Code
+15
32 节点DIGITAL BIZ TECH
Support Chatbot
邮件历史RAG
使用Gmail、OpenAI和Qdrant向量数据库创建邮件知识库
Code
Gmail
Gmail Trigger
+11
23 节点Zain Ali
Internal Wiki
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
Other
上下文混合RAG AI文案
Google Drive到Supabase上下文向量数据库同步用于RAG应用
If
Set
Code
+25
76 节点Michael Taleb
AI RAG
Blockify工作流模板
使用Blockify IdeaBlocks技术优化非结构化数据用于RAG
Set
Code
Google Drive
+12
22 节点Iternal Technologies
AI RAG
我的智能体竞技场社区竞赛
使用Qdrant、Mistral OCR和GPT-4构建基于RAG的问答系统
Set
Code
Wait
+19
41 节点Davide
Content Creation