Système RAG complet avec Qdrant et citations automatiques des sources
Ceci est unAI, IT Opsworkflow d'automatisation du domainecontenant 29 nœuds.Utilise principalement des nœuds comme Set, Code, Wait, Merge, Aggregate, combinant la technologie d'intelligence artificielle pour une automatisation intelligente. Construire un système RAG avec citations automatiques avec Qdrant, Gemini et OpenAI
- •Informations d'identification Google Drive API
- •Peut nécessiter les informations d'identification d'authentification de l'API cible
- •Clé API OpenAI
- •Informations de connexion au serveur Qdrant
- •Clé API Google Gemini
Nœuds utilisés (29)
{
"id": "OAvKQCYsly0DTlci",
"meta": {
"instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462",
"templateCredsSetupCompleted": true
},
"name": "Complete RAG System with Automatic Source Citations Using Qdrant",
"tags": [],
"nodes": [
{
"id": "65d3e882-ef84-4b3b-88b0-bb69bbe6886f",
"name": "Lors du clic sur 'Tester le workflow'",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-400,
220
],
"parameters": {},
"typeVersion": 1
},
{
"id": "db531b5a-588a-4982-aa00-e565d6f5610b",
"name": "Embeddings 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": "Default Data Loader1",
"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 Vector Store",
"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": "Créer une collection",
"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": "Recursive Character Text Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"position": [
1060,
660
],
"parameters": {
"options": {},
"chunkSize": 500,
"chunkOverlap": 50
},
"typeVersion": 1
},
{
"id": "1311350d-75d3-4edc-8fa9-584a1c36da6d",
"name": "Boucle sur les éléments",
"type": "n8n-nodes-base.splitInBatches",
"position": [
420,
220
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "1f9b623c-4e93-44da-8c9d-cfe9f5d5be9a",
"name": "Attente",
"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": "Lors de la réception d'un message de chat",
"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 Chat Model",
"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 Vector Store1",
"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": "Embeddings 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": "Embeddings 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": "Merge1",
"type": "n8n-nodes-base.merge",
"position": [
640,
1140
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineAll"
},
"typeVersion": 3.1
},
{
"id": "2edbca72-220e-45a6-8295-830d58611549",
"name": "Agrégation",
"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": "Vider la collection",
"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": "Obtenir le dossier",
"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": "Obtenir le fichier",
"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": "chatInput",
"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": "Récupérer les sources",
"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": "Sortie",
"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": "Réponse",
"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": "Note adhésive2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-360,
-520
],
"parameters": {
"width": 840,
"height": 220,
"content": "## Complete RAG System with Automatic Source Citations Using Qdrant\n\nThis workflow implements a **Retrieval-Augmented Generation (RAG)** system that:\n\n* Stores vectorized documents in **Qdrant**,\n* Retrieves relevant content based on user input,\n* Generates AI answers using **Google Gemini**,\n* Automatically **cites the document sources** (from Google Drive).\n"
},
"typeVersion": 1
},
{
"id": "3220c323-a3d6-4855-ad05-2aaf8761771e",
"name": "Note adhésive3",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-200
],
"parameters": {
"color": 6,
"width": 880,
"height": 220,
"content": "# STEP 1\n\n## Create Qdrant Collection\nChange:\n- QDRANTURL\n- COLLECTION"
},
"typeVersion": 1
},
{
"id": "738835a3-888b-426e-a897-8ddc630b85bf",
"name": "Note adhésive4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-220,
120
],
"parameters": {
"color": 4,
"width": 620,
"height": 520,
"content": "# STEP 2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Documents vectorization with Qdrant and Google Drive\nChange:\n- QDRANTURL\n- COLLECTION"
},
"typeVersion": 1
},
{
"id": "70205511-2c4a-4f2f-8f68-97e3ede28851",
"name": "Note adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
1200,
620
],
"parameters": {
"color": 4,
"width": 520,
"height": 420,
"content": "Set as metadata:\n- FILE_ID from Google Drive\n- FILE_NAME from Google Drive\n\n```\n{\n \"source\": \"blob\",\n \"blobType\": \"text/plain\",\n \"loc\": {\n \"lines\": {\n \"from\": 1,\n \"to\": 15\n }\n },\n \"file_id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"file_name\": \"FAQ\"\n}\n```\n\n\n"
},
"typeVersion": 1
},
{
"id": "921497ff-1beb-4bd1-aecd-81b68c5a0357",
"name": "Note adhésive1",
"type": "n8n-nodes-base.stickyNote",
"position": [
680,
1400
],
"parameters": {
"color": 3,
"width": 520,
"height": 200,
"content": "The final output is:\n\n\nRESPONSE\n\nSources: [\"FILENAME 1\", \"FILENAME 2\",...]\n\n"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "33d05a21-33dd-422a-ba58-3eafffc7d50a",
"connections": {
"1f9b623c-4e93-44da-8c9d-cfe9f5d5be9a": {
"main": [
[
{
"node": "1311350d-75d3-4edc-8fa9-584a1c36da6d",
"type": "main",
"index": 0
}
]
]
},
"d0d32470-b1df-40ec-aac1-32e4c9cf2e4e": {
"main": [
[
{
"node": "9407fcaf-d90a-46bd-9b1f-b0493a0357c1",
"type": "main",
"index": 0
}
]
]
},
"e81ee92f-db50-4c62-aac7-7bc03e63cc1a": {
"main": [
[
{
"node": "9923f6be-c2a5-4498-9fd2-0ed74ccdab35",
"type": "main",
"index": 0
}
]
]
},
"9407fcaf-d90a-46bd-9b1f-b0493a0357c1": {
"main": [
[
{
"node": "265e2613-0155-4585-8d5c-fcda26975585",
"type": "main",
"index": 0
}
]
]
},
"2edbca72-220e-45a6-8295-830d58611549": {
"main": [
[
{
"node": "d0d32470-b1df-40ec-aac1-32e4c9cf2e4e",
"type": "main",
"index": 0
}
]
]
},
"c9bdc00a-ca8c-4457-8720-e6dce07e6b22": {
"main": [
[
{
"node": "1e132fba-00a5-414a-8f37-f34645f668ff",
"type": "main",
"index": 0
},
{
"node": "b65ca747-e738-4b7a-ae02-83840ce0a460",
"type": "main",
"index": 0
}
]
]
},
"0d4d3bab-2370-4ced-8f5d-2977d360f72b": {
"main": [
[
{
"node": "1311350d-75d3-4edc-8fa9-584a1c36da6d",
"type": "main",
"index": 0
}
]
]
},
"1311350d-75d3-4edc-8fa9-584a1c36da6d": {
"main": [
[],
[
{
"node": "e81ee92f-db50-4c62-aac7-7bc03e63cc1a",
"type": "main",
"index": 0
}
]
]
},
"b65ca747-e738-4b7a-ae02-83840ce0a460": {
"main": [
[
{
"node": "2edbca72-220e-45a6-8295-830d58611549",
"type": "main",
"index": 0
}
]
]
},
"8d116bc2-73d8-4349-8b4e-8dc0aef7cfa3": {
"main": [
[
{
"node": "0d4d3bab-2370-4ced-8f5d-2977d360f72b",
"type": "main",
"index": 0
}
]
]
},
"6cfe7e8a-e593-4e4e-a0be-3379dd85c748": {
"ai_embedding": [
[
{
"node": "0c7d1804-4525-4117-a19d-f2d59195fd47",
"type": "ai_embedding",
"index": 0
}
]
]
},
"db531b5a-588a-4982-aa00-e565d6f5610b": {
"ai_embedding": [
[
{
"node": "9923f6be-c2a5-4498-9fd2-0ed74ccdab35",
"type": "ai_embedding",
"index": 0
}
]
]
},
"d9aa08b5-ed04-4506-9a2e-f994d4694f48": {
"ai_embedding": [
[
{
"node": "b65ca747-e738-4b7a-ae02-83840ce0a460",
"type": "ai_embedding",
"index": 0
}
]
]
},
"9923f6be-c2a5-4498-9fd2-0ed74ccdab35": {
"main": [
[
{
"node": "1f9b623c-4e93-44da-8c9d-cfe9f5d5be9a",
"type": "main",
"index": 0
}
]
]
},
"5a1606d8-d851-4fb1-a18a-a45f5de3adf2": {
"ai_document": [
[
{
"node": "9923f6be-c2a5-4498-9fd2-0ed74ccdab35",
"type": "ai_document",
"index": 0
}
]
]
},
"0c7d1804-4525-4117-a19d-f2d59195fd47": {
"ai_vectorStore": [
[
{
"node": "ad8cec62-ce1d-4e58-8e40-9a7a9f4f93c7",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"ad8cec62-ce1d-4e58-8e40-9a7a9f4f93c7": {
"ai_retriever": [
[
{
"node": "1e132fba-00a5-414a-8f37-f34645f668ff",
"type": "ai_retriever",
"index": 0
}
]
]
},
"badee75e-bca7-49e4-9095-c098cb7adcab": {
"ai_languageModel": [
[
{
"node": "1e132fba-00a5-414a-8f37-f34645f668ff",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"1e132fba-00a5-414a-8f37-f34645f668ff": {
"main": [
[
{
"node": "d0d32470-b1df-40ec-aac1-32e4c9cf2e4e",
"type": "main",
"index": 1
}
]
]
},
"22aacdc0-8ec5-42e2-b9a0-fb9e5a4aa23c": {
"main": [
[
{
"node": "c9bdc00a-ca8c-4457-8720-e6dce07e6b22",
"type": "main",
"index": 0
}
]
]
},
"e0936863-4ece-429c-bf32-49f75b5c8bf0": {
"ai_textSplitter": [
[
{
"node": "5a1606d8-d851-4fb1-a18a-a45f5de3adf2",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"65d3e882-ef84-4b3b-88b0-bb69bbe6886f": {
"main": [
[
{
"node": "8d116bc2-73d8-4349-8b4e-8dc0aef7cfa3",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Avancé - Intelligence Artificielle, Opérations IT
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
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
Partager ce workflow