mirror of
https://github.com/coleam00/ai-agents-masterclass.git
synced 2025-11-29 00:23:14 +00:00
AI Agents Masterclass #9 - n8n RAG Agent
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "Add Google Drive File to Vector DB Webhook",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "62e355b9-f29e-4542-bc69-0862451611b5",
|
||||
"name": "Execute Workflow Trigger",
|
||||
"type": "n8n-nodes-base.executeWorkflowTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
720,
|
||||
300
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://n8n.yoururl.com/webhook/add_doc_to_vector_db",
|
||||
"authentication": "genericCredentialType",
|
||||
"genericAuthType": "httpHeaderAuth",
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "query",
|
||||
"value": "={{ $json.query.query }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "41af8ec1-258f-43dd-82ad-be28b323d83b",
|
||||
"name": "HTTP Request",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
940,
|
||||
300
|
||||
],
|
||||
"credentials": {
|
||||
"httpHeaderAuth": {
|
||||
"id": "FWbnHWdNKFyEHa1W",
|
||||
"name": "Header Auth account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {},
|
||||
"connections": {
|
||||
"Execute Workflow Trigger": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "HTTP Request",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "a117a9b8-1c53-4548-b9cd-1f776f61b798",
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true,
|
||||
"instanceId": "620f0d7e3114cb344761d7d45a21ef2a32096f91d8696e7057756042e1999e2c"
|
||||
},
|
||||
"id": "VYQ5kVPM57CJavof",
|
||||
"tags": []
|
||||
}
|
||||
534
9-n8n-rag-agent/n8n_Workflow_RAG_AI_Agent.json
Normal file
534
9-n8n-rag-agent/n8n_Workflow_RAG_AI_Agent.json
Normal file
@@ -0,0 +1,534 @@
|
||||
{
|
||||
"name": "RAG AI Agent",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"model": "gpt-4o-mini",
|
||||
"options": {}
|
||||
},
|
||||
"id": "33ff568b-7ff5-4693-b00b-d788cde46c0b",
|
||||
"name": "OpenAI Chat Model",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1060,
|
||||
520
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "JJjD91oisPv9cs01",
|
||||
"name": "OpenAi account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"sessionIdType": "customKey",
|
||||
"sessionKey": "={{ $('When chat message received').item.json.sessionId }}"
|
||||
},
|
||||
"id": "f7f4e28a-0d29-4eb7-978d-95df0e56a3ae",
|
||||
"name": "Window Buffer Memory",
|
||||
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
1200,
|
||||
520
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": "gpt-4o-mini",
|
||||
"options": {}
|
||||
},
|
||||
"id": "0fe1d709-eb31-4110-830e-167e3a551eb2",
|
||||
"name": "OpenAI Chat Model1",
|
||||
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1940,
|
||||
760
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "JJjD91oisPv9cs01",
|
||||
"name": "OpenAi account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "fileFolder",
|
||||
"queryString": "={{ $json.query.query }}",
|
||||
"limit": 1,
|
||||
"filter": {},
|
||||
"options": {}
|
||||
},
|
||||
"id": "63cd26be-3e7e-4bc0-bb3e-4d66784e3585",
|
||||
"name": "Google Drive",
|
||||
"type": "n8n-nodes-base.googleDrive",
|
||||
"typeVersion": 3,
|
||||
"position": [
|
||||
440,
|
||||
780
|
||||
],
|
||||
"credentials": {
|
||||
"googleDriveOAuth2Api": {
|
||||
"id": "cfNochbuJikPwwl2",
|
||||
"name": "Google Drive account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "download",
|
||||
"fileId": {
|
||||
"__rl": true,
|
||||
"value": "={{ $json.id }}",
|
||||
"mode": "id"
|
||||
},
|
||||
"options": {
|
||||
"binaryPropertyName": "data",
|
||||
"googleFileConversion": {
|
||||
"conversion": {
|
||||
"docsToFormat": "text/plain"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "4db2b70d-4fc9-4e7c-b987-5f2258da3b16",
|
||||
"name": "Get File Content",
|
||||
"type": "n8n-nodes-base.googleDrive",
|
||||
"typeVersion": 3,
|
||||
"position": [
|
||||
660,
|
||||
780
|
||||
],
|
||||
"credentials": {
|
||||
"googleDriveOAuth2Api": {
|
||||
"id": "cfNochbuJikPwwl2",
|
||||
"name": "Google Drive account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsonMode": "expressionData",
|
||||
"jsonData": "={{ $json.data }}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "b0f5c545-ae2d-4a66-be57-ce554d8e615e",
|
||||
"name": "Default Data Loader",
|
||||
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1200,
|
||||
1000
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "89c7d5f5-99be-4ffe-92ef-32fa53c06c1f",
|
||||
"name": "Character Text Splitter",
|
||||
"type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1200,
|
||||
1180
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "text",
|
||||
"options": {}
|
||||
},
|
||||
"id": "cf4ab541-026f-4ec2-9875-c575a5ae75d8",
|
||||
"name": "Extract from File",
|
||||
"type": "n8n-nodes-base.extractFromFile",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
780
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": "text-embedding-3-large",
|
||||
"options": {}
|
||||
},
|
||||
"id": "dad0f35a-e10d-4192-b614-86e37de826ce",
|
||||
"name": "Embeddings OpenAI1",
|
||||
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1040,
|
||||
1000
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "JJjD91oisPv9cs01",
|
||||
"name": "OpenAi account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"model": "text-embedding-3-large",
|
||||
"options": {}
|
||||
},
|
||||
"id": "bf80fd4d-0f65-4683-8f44-b973bfb6bb27",
|
||||
"name": "Embeddings OpenAI",
|
||||
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1760,
|
||||
840
|
||||
],
|
||||
"credentials": {
|
||||
"openAiApi": {
|
||||
"id": "JJjD91oisPv9cs01",
|
||||
"name": "OpenAi account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "add_doc_to_vector_db",
|
||||
"authentication": "headerAuth",
|
||||
"responseMode": "lastNode",
|
||||
"options": {}
|
||||
},
|
||||
"id": "2f39795b-02cd-4e0e-9229-f55526b9f28a",
|
||||
"name": "Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
220,
|
||||
780
|
||||
],
|
||||
"webhookId": "8ea31a69-552f-445a-9584-47b869da88fd",
|
||||
"credentials": {
|
||||
"httpHeaderAuth": {
|
||||
"id": "FWbnHWdNKFyEHa1W",
|
||||
"name": "Header Auth account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"name": "add_file_to_vector_db",
|
||||
"description": "Use this to search for a file in Google Drive, download it, and add it to the vector DB knowledgebase for future querying.",
|
||||
"workflowId": "VYQ5kVPM57CJavof",
|
||||
"responsePropertyName": "metadata",
|
||||
"specifyInputSchema": true,
|
||||
"jsonSchemaExample": "{\n\t\"query\": \"Meeting notes from last week\"\n}"
|
||||
},
|
||||
"id": "4e1df3b5-e802-482c-9f35-2d36f90d66b9",
|
||||
"name": "Add Google Drive File to Vector DB",
|
||||
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
1560,
|
||||
620
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"name": "user_documents",
|
||||
"description": "Contains all the user's documents that you can check for context to answer user questions."
|
||||
},
|
||||
"id": "79343f67-0eec-4c8b-923c-87e731a18858",
|
||||
"name": "Retrieve Documents",
|
||||
"type": "@n8n/n8n-nodes-langchain.toolVectorStore",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1760,
|
||||
620
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"content": "## Agent Tools for RAG",
|
||||
"height": 528.85546469693,
|
||||
"width": 583.4552380860637,
|
||||
"color": 4
|
||||
},
|
||||
"id": "241c3005-9fb6-45fd-be5e-31a3eb95c64e",
|
||||
"name": "Sticky Note",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1480,
|
||||
440
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"content": "## Tool to Add a Google Drive File to Vector DB",
|
||||
"height": 661.3783861449286,
|
||||
"width": 1290.2441524753906,
|
||||
"color": 5
|
||||
},
|
||||
"id": "d7317244-3528-4cd8-b68e-a4c6d7521589",
|
||||
"name": "Sticky Note1",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
180,
|
||||
700
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"content": "## RAG AI Agent with Chat Interface",
|
||||
"height": 464.8027193303974,
|
||||
"width": 692.7866482806627
|
||||
},
|
||||
"id": "2755e53b-bcfa-41af-bd23-f33122e6aad0",
|
||||
"name": "Sticky Note2",
|
||||
"type": "n8n-nodes-base.stickyNote",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
780,
|
||||
220
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"promptType": "define",
|
||||
"text": "={{ $('When chat message received').item.json.chatInput }}",
|
||||
"options": {
|
||||
"systemMessage": "You are a personal assistant who helps answer questions from a corpus of documents when you don't know the answer yourself."
|
||||
}
|
||||
},
|
||||
"id": "018af08d-ae24-4c3a-955d-fa28de9f37b5",
|
||||
"name": "RAG AI Agent",
|
||||
"type": "@n8n/n8n-nodes-langchain.agent",
|
||||
"typeVersion": 1.6,
|
||||
"position": [
|
||||
1160,
|
||||
300
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"memoryKey": "user_documents"
|
||||
},
|
||||
"id": "7de087ea-258b-448f-ad81-cb76a7467cfe",
|
||||
"name": "In-Memory Vector Store",
|
||||
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1660,
|
||||
740
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"mode": "insert",
|
||||
"memoryKey": "=user_documents"
|
||||
},
|
||||
"id": "dc9aecd0-3fd7-4306-9ce5-5cbde0f8e5dd",
|
||||
"name": "In-Memory Vector Store Inserter",
|
||||
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1120,
|
||||
780
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"options": {}
|
||||
},
|
||||
"id": "fac880f8-9155-4f6d-bf5f-921643eac390",
|
||||
"name": "When chat message received",
|
||||
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
840,
|
||||
300
|
||||
],
|
||||
"webhookId": "057f6fe7-e865-42b6-9020-8cc759271eb9"
|
||||
}
|
||||
],
|
||||
"pinData": {},
|
||||
"connections": {
|
||||
"OpenAI Chat Model": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "RAG AI Agent",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Window Buffer Memory": {
|
||||
"ai_memory": [
|
||||
[
|
||||
{
|
||||
"node": "RAG AI Agent",
|
||||
"type": "ai_memory",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OpenAI Chat Model1": {
|
||||
"ai_languageModel": [
|
||||
[
|
||||
{
|
||||
"node": "Retrieve Documents",
|
||||
"type": "ai_languageModel",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Google Drive": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get File Content",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get File Content": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract from File",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Default Data Loader": {
|
||||
"ai_document": [
|
||||
[
|
||||
{
|
||||
"node": "In-Memory Vector Store Inserter",
|
||||
"type": "ai_document",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Character Text Splitter": {
|
||||
"ai_textSplitter": [
|
||||
[
|
||||
{
|
||||
"node": "Default Data Loader",
|
||||
"type": "ai_textSplitter",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract from File": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "In-Memory Vector Store Inserter",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Embeddings OpenAI1": {
|
||||
"ai_embedding": [
|
||||
[
|
||||
{
|
||||
"node": "In-Memory Vector Store Inserter",
|
||||
"type": "ai_embedding",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Embeddings OpenAI": {
|
||||
"ai_embedding": [
|
||||
[
|
||||
{
|
||||
"node": "In-Memory Vector Store",
|
||||
"type": "ai_embedding",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Google Drive",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Add Google Drive File to Vector DB": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "RAG AI Agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Retrieve Documents": {
|
||||
"ai_tool": [
|
||||
[
|
||||
{
|
||||
"node": "RAG AI Agent",
|
||||
"type": "ai_tool",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"In-Memory Vector Store": {
|
||||
"ai_vectorStore": [
|
||||
[
|
||||
{
|
||||
"node": "Retrieve Documents",
|
||||
"type": "ai_vectorStore",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"When chat message received": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "RAG AI Agent",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "fb0f8eba-375e-4dd4-a25f-4eb1d99e1faf",
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true,
|
||||
"instanceId": "620f0d7e3114cb344761d7d45a21ef2a32096f91d8696e7057756042e1999e2c"
|
||||
},
|
||||
"id": "HuSVDGWbGX8K09N1",
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user