Reordenamiento de RAG
Este es unInternal Wiki, AI RAGflujo de automatización del dominio deautomatización que contiene 26 nodos.Utiliza principalmente nodos como Code, GoogleDrive, ManualTrigger, Agent, ExtractFromFile. Usar Supabase, OpenAI y reordenador de Cohere para responder preguntas a partir de documentos
- •Credenciales de API de Google Drive
- •Clave de API de OpenAI
- •URL y Clave de API de Supabase
Nodos utilizados (26)
Categoría
{
"id": "p8bHqYEvjtOrvz3q",
"meta": {
"instanceId": "",
"templateCredsSetupCompleted": true
},
"name": "RAG Reranking",
"tags": [],
"nodes": [
{
"id": "d690d954-6291-4355-9b51-42fe9ab2791a",
"name": "Descargar Archivo",
"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": "Cargador de Datos Predeterminado",
"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": "Extraer de Archivo",
"type": "n8n-nodes-base.extractFromFile",
"position": [
40,
-320
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "dfc604ab-b7bd-4a08-b65d-f8fe2c3b5c13",
"name": "Código",
"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": "Cuando se recibe mensaje de chat",
"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": "Reordenador 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": "Subir a 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": "Almacén Vectorial 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": "Reordenador Cohere1",
"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": "Embeddings OpenAI2",
"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": "Almacén Vectorial Supabase1",
"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": "Nota Adhesiva",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
-460
],
"parameters": {
"color": 2,
"width": 1000,
"height": 440,
"content": "# Vectorize Document w/ Metadata\n(this code node is set up for the golf rules PDF specifically)"
},
"typeVersion": 1
},
{
"id": "406521ff-0f01-4688-a352-62ae49d71ff6",
"name": "Nota Adhesiva1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
-1280
],
"parameters": {
"color": 4,
"width": 620,
"height": 380,
"content": "# RAG Agent\n"
},
"typeVersion": 1
},
{
"id": "11f6a7fd-b540-43d9-ad55-86c2874e8ddd",
"name": "Nota Adhesiva2",
"type": "n8n-nodes-base.stickyNote",
"position": [
300,
-1280
],
"parameters": {
"color": 5,
"width": 380,
"height": 380,
"content": "## Vector Store w/ Reranker\n"
},
"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": "Agente de Metadatos",
"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": "Agente RAG",
"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": "Agente 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": "Nota Adhesiva3",
"type": "n8n-nodes-base.stickyNote",
"position": [
120,
-880
],
"parameters": {
"color": 4,
"width": 440,
"height": 400,
"content": "# RAG Agent\n"
},
"typeVersion": 1
},
{
"id": "ede1b0d8-d402-4fa5-abe0-8ee4169be45b",
"name": "Nota Adhesiva4",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
-880
],
"parameters": {
"color": 5,
"width": 380,
"height": 400,
"content": "## Vector Store w/ Reranker & Metadata\n"
},
"typeVersion": 1
},
{
"id": "c56cce9d-2d8c-4942-94fa-a8d62e062842",
"name": "Nota Adhesiva5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
-880
],
"parameters": {
"color": 6,
"width": 440,
"height": 400,
"content": "# Metadata Agent\n"
},
"typeVersion": 1
},
{
"id": "7e6dd534-9f8a-42c2-bac0-0bb0e4fa99e6",
"name": "Activador Manual",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-240,
-320
],
"parameters": {},
"typeVersion": 1
},
{
"id": "85ee82ce-f0b2-49f0-852e-9b888b9235a9",
"name": "Nota Adhesiva6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1040,
-1280
],
"parameters": {
"width": 700,
"height": 800,
"content": "# 🛠️ Setup Guide \n**Author:** [Nate Herk](https://www.youtube.com/@nateherk)\n\nFollow the steps below to get your Retrieval-Augmented Generation (RAG) workflow up and running:\n\n### ✅ Step 1: Connect Your [Supabase](https://supabase.com/) Vector Store \nEnsure your Supabase instance is ready and accessible. This will store your embedded documents with metadata.\nHere is a [video tutorial](https://youtu.be/JjBofKJnYIU) on setting that up.\n\n### ✅ Step 2: Connect Your [OpenAI](https://platform.openai.com/account/api-keys) Embeddings \nUse the `text-embedding-3-small` or similar model for embedding your documents. Make sure your API key is active.\n\n### ✅ Step 3: Connect Your [OpenAI API Key](https://platform.openai.com/account/api-keys) \nThis powers your embedding generation model. Add it via the HTTP Request node or a credential.\n\n### ✅ Step 4: Add Your [OpenRouter](https://openrouter.ai/) API Key \nUse this for your main RAG agent—add your key via HTTP request or credential node.\n\n### ✅ Step 5: Connect a [Cohere](https://dashboard.cohere.com/api-keys) Re-Ranker \nThe re-ranker improves answer quality. Add your API key for better relevance ranking on retrieved documents.\n\n### ✅ Step 6: Vectorize Documents with Metadata \nEnsure your data ingestion process tags documents with meaningful metadata before vectorization. This helps with structured retrieval.\n\n### 💬 Final Step: Start Chatting \nPrompt your agent and test the RAG flow end-to-end—watch it pull context-rich answers from your vector store.\n"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "80eccd78-53ac-4cca-aedd-63ddf77ff7af",
"connections": {
"dfc604ab-b7bd-4a08-b65d-f8fe2c3b5c13": {
"main": [
[
{
"node": "24cbdd3d-afee-46d2-83ef-888d432b4874",
"type": "main",
"index": 0
}
]
]
},
"9f02235d-8c3f-4309-bd14-d4c6bcdfab11": {
"ai_languageModel": [
[
{
"node": "9fbd11cd-195d-4bbe-aa81-718c063d1133",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"d690d954-6291-4355-9b51-42fe9ab2791a": {
"main": [
[
{
"node": "f6d44c38-8cb4-43ad-8130-7ab8cd142c9a",
"type": "main",
"index": 0
}
]
]
},
"de08fce1-3db6-4452-a30a-27294328bdb9": {
"ai_languageModel": [
[
{
"node": "150a92c9-fdb4-45e0-a838-45364dd6140b",
"type": "ai_languageModel",
"index": 0
},
{
"node": "62282da2-0dc5-4758-8182-13a7bf1afff9",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"7e6dd534-9f8a-42c2-bac0-0bb0e4fa99e6": {
"main": [
[
{
"node": "d690d954-6291-4355-9b51-42fe9ab2791a",
"type": "main",
"index": 0
}
]
]
},
"62282da2-0dc5-4758-8182-13a7bf1afff9": {
"main": [
[
{
"node": "150a92c9-fdb4-45e0-a838-45364dd6140b",
"type": "main",
"index": 0
}
]
]
},
"dad869f9-4c1d-44a4-b523-31f007efccc7": {
"ai_reranker": [
[
{
"node": "f80184cb-fc7e-40d7-bf2d-a723350c9f0f",
"type": "ai_reranker",
"index": 0
}
]
]
},
"2fbb1dbc-aeb3-4f5d-b1b1-f8947bec45e4": {
"ai_reranker": [
[
{
"node": "fe882466-73db-4141-8c70-baff299b4e1c",
"type": "ai_reranker",
"index": 0
}
]
]
},
"5b11e4ea-c497-4d18-8dfe-3dcdcadde1e6": {
"ai_embedding": [
[
{
"node": "f80184cb-fc7e-40d7-bf2d-a723350c9f0f",
"type": "ai_embedding",
"index": 0
}
]
]
},
"f6d44c38-8cb4-43ad-8130-7ab8cd142c9a": {
"main": [
[
{
"node": "dfc604ab-b7bd-4a08-b65d-f8fe2c3b5c13",
"type": "main",
"index": 0
}
]
]
},
"d295d851-b64b-41c9-9289-f7c5c640b704": {
"ai_embedding": [
[
{
"node": "24cbdd3d-afee-46d2-83ef-888d432b4874",
"type": "ai_embedding",
"index": 0
}
]
]
},
"64140fce-9e7c-4cd2-a5ba-2bfb4c8bdaad": {
"ai_embedding": [
[
{
"node": "fe882466-73db-4141-8c70-baff299b4e1c",
"type": "ai_embedding",
"index": 0
}
]
]
},
"ad9a4d3c-ace1-428c-8957-edb456bf864f": {
"ai_document": [
[
{
"node": "24cbdd3d-afee-46d2-83ef-888d432b4874",
"type": "ai_document",
"index": 0
}
]
]
},
"f80184cb-fc7e-40d7-bf2d-a723350c9f0f": {
"ai_tool": [
[
{
"node": "9fbd11cd-195d-4bbe-aa81-718c063d1133",
"type": "ai_tool",
"index": 0
}
]
]
},
"fe882466-73db-4141-8c70-baff299b4e1c": {
"ai_tool": [
[
{
"node": "150a92c9-fdb4-45e0-a838-45364dd6140b",
"type": "ai_tool",
"index": 0
}
]
]
},
"cc659be4-709e-4d59-a386-d7cc60166293": {
"main": [
[
{
"node": "9fbd11cd-195d-4bbe-aa81-718c063d1133",
"type": "main",
"index": 0
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Avanzado - Wiki interno, RAG de IA
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
Compartir este flujo de trabajo