{
  "name": "Create adaptive RAG chat agent with Google Gemini and Qdrant",
  "nodes": [
    {
      "id": "6cccf7c5-9d8b-4f11-a7e1-c1bcf48bb9fe",
      "name": "Query Classification",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -660,
        880
      ]
    },
    {
      "id": "937104bc-5756-4adb-af0b-3e8741536e44",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -300,
        860
      ]
    },
    {
      "id": "7346bf45-3f9b-4717-8cb5-52d829f0826c",
      "name": "Factual Strategy - Focus on Precision",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        100,
        120
      ]
    },
    {
      "id": "ac1df57d-524c-4393-a81c-fb720f19b05e",
      "name": "Analytical Strategy - Comprehensive Coverage",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        100,
        660
      ]
    },
    {
      "id": "7df8350e-4f18-47fb-bd9a-c0238d218603",
      "name": "Opinion Strategy - Diverse Perspectives",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        100,
        1200
      ]
    },
    {
      "id": "0f9ef12d-7df4-4255-b5e2-27eb4e7ce982",
      "name": "Contextual Strategy - User Context Integration",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        100,
        1740
      ]
    },
    {
      "id": "3c04f8e8-1304-436d-86eb-d905aa1cc261",
      "name": "Chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1320,
        1020
      ]
    },
    {
      "id": "e1daa9fc-62d2-4664-a9f3-dcdecf9071e6",
      "name": "Factual Prompt and Output",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        120
      ]
    },
    {
      "id": "1429dfd5-709d-4065-9134-05820fad871b",
      "name": "Contextual Prompt and Output",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        1740
      ]
    },
    {
      "id": "01c57856-4378-4085-bb67-2edf9b1164f9",
      "name": "Opinion Prompt and Output",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        1200
      ]
    },
    {
      "id": "3cb3f5e1-c85c-4481-a147-8b3c419526ee",
      "name": "Analytical Prompt and Output",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        660
      ]
    },
    {
      "id": "34577e85-b067-49dd-90a6-048805de5118",
      "name": "Gemini Classification",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -680,
        1080
      ]
    },
    {
      "id": "7257c1dd-56bb-4f50-b206-2edd55fdd7cf",
      "name": "Gemini Factual",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        80,
        340
      ]
    },
    {
      "id": "47465499-74e8-4425-913a-2efd5c5e3441",
      "name": "Gemini Analytical",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        80,
        880
      ]
    },
    {
      "id": "a7273940-82c8-44a9-8890-b00c1a741015",
      "name": "Chat Buffer Memory Analytical",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        240,
        880
      ]
    },
    {
      "id": "6b573a7d-a6f0-4290-b3f1-3e36785bbee1",
      "name": "Chat Buffer Memory Factual",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        240,
        340
      ]
    },
    {
      "id": "9b20e2d9-9c67-45a0-9dfe-03bafb62f67f",
      "name": "Gemini Opinion",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        80,
        1420
      ]
    },
    {
      "id": "70489752-18b8-4676-a700-539c7b0fecb3",
      "name": "Chat Buffer Memory Opinion",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        240,
        1420
      ]
    },
    {
      "id": "e32a0ce3-2f72-43ca-b12a-03e3cf1b7818",
      "name": "Gemini Contextual",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        80,
        1960
      ]
    },
    {
      "id": "75c4f677-4c78-4a22-b0b4-44f3882c1a4e",
      "name": "Chat Buffer Memory Contextual",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        240,
        1960
      ]
    },
    {
      "id": "31d68f85-3cfc-4c93-81f7-c27070bf7307",
      "name": "Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        1020,
        1100
      ]
    },
    {
      "id": "53910aea-7326-4d59-8585-693cb05afc3e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 700,
        "height": 520,
        "content": "## Factual Strategy\n**Retrieve precise facts and figures.**"
      }
    },
    {
      "id": "87015bf7-0bf1-490f-90b4-96346cc51b7c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        540
      ],
      "parameters": {
        "width": 700,
        "height": 520,
        "content": "## Analytical Strategy\n**Provide comprehensive coverage of a topics and exploring different aspects.**"
      }
    },
    {
      "id": "b14886e0-e513-405d-92d5-d4a417280546",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        1080
      ],
      "parameters": {
        "width": 700,
        "height": 520,
        "content": "## Opinion Strategy\n**Gather diverse viewpoints on a subjective issue.**"
      }
    },
    {
      "id": "77cd1373-d547-462b-85cb-6799e7fbae84",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        1620
      ],
      "parameters": {
        "width": 700,
        "height": 520,
        "content": "## Contextual Strategy\n**Incorporate user-specific context to fine-tune the retrieval.**"
      }
    },
    {
      "id": "edfe1620-b040-466c-a8b2-a6f2aae565c5",
      "name": "Concatenate Context",
      "type": "n8n-nodes-base.summarize",
      "position": [
        1400,
        880
      ]
    },
    {
      "id": "059f5b2e-52db-49f6-bee8-9dfcd5fd1ea4",
      "name": "Retrieve Documents from Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        1040,
        880
      ]
    },
    {
      "id": "d1a2de81-c92b-459a-a2b6-bb6d171ba712",
      "name": "Set Prompt and Output",
      "type": "n8n-nodes-base.set",
      "position": [
        840,
        880
      ]
    },
    {
      "id": "aa7dede0-8241-4428-84db-7a403935a052",
      "name": "Gemini Answer",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1680,
        1100
      ]
    },
    {
      "id": "5a33f53d-2297-46a1-9508-54c1e4f168be",
      "name": "Answer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1720,
        880
      ]
    },
    {
      "id": "888d1b5e-151f-4fb7-a201-fa8706af6ae8",
      "name": "Chat Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1860,
        1100
      ]
    },
    {
      "id": "573efafe-0dca-46d9-98a9-2684277d411d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        760,
        680
      ],
      "parameters": {
        "width": 820,
        "height": 580,
        "content": "## Perform adaptive retrieval\n**Find document considering both query and context.**"
      }
    },
    {
      "id": "f4219ef7-16ce-4cc6-8b03-a9480b2daf55",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        680
      ],
      "parameters": {
        "width": 740,
        "height": 580,
        "content": "## Reply to the user integrating retrieval context"
      }
    },
    {
      "id": "4fe79c8d-9670-4b2a-a7c7-5a2239906a14",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2080,
        880
      ]
    },
    {
      "id": "ff99bc5a-bbbe-457d-b979-2ca1e04bd980",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -760,
        680
      ],
      "parameters": {
        "width": 700,
        "height": 580,
        "content": "## User query classification\n**Classify the query into one of four categories: Factual, Analytical, Opinion, or Contextual.**"
      }
    },
    {
      "id": "c632a735-5a96-4a70-bf4c-6126e2e193f1",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1320,
        760
      ]
    },
    {
      "id": "332b925d-0581-4b92-a7ce-83cbc8f66254",
      "name": "Combined Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -1000,
        880
      ]
    },
    {
      "id": "eab0d609-5d9b-4794-adb5-fd8a784f34b0",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1340,
        1300
      ],
      "parameters": {
        "width": 1280,
        "height": 1300,
        "content": "# Adaptive RAG Workflow\n\nThis n8n workflow implements a version of the Adaptive Retrieval-Augmented Generation (RAG) approach. It classifies user queries and applies different retrieval and generation"
      }
    },
    {
      "id": "1580b44f-bd48-43f8-b9ef-dbfd58042e68",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        680
      ],
      "parameters": {
        "width": 320,
        "height": 580,
        "content": "## ⚠️  If using in Chat mode\n\nUpdate the `vector_store_id` variable to the corresponding Qdrant ID needed to perform the documents retrieval."
      }
    },
    {
      "id": "df475a3d-cec6-4a29-8d33-cfe8a1ae3d6c",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1720,
        1300
      ],
      "parameters": {
        "width": 360,
        "height": 200,
        "content": "## Quantra Labs \nFollow Us\nhttps://www.x.com/quantralabs\n\nConnect with Us\nhttps://www.linkedin.com/company/quantra-labs\n\nwww.quantralabs.com"
      }
    }
  ],
  "connections": {
    "Chat": {
      "main": [
        [
          {
            "node": "Combined Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Factual Strategy - Focus on Precision",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Analytical Strategy - Comprehensive Coverage",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Opinion Strategy - Diverse Perspectives",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Contextual Strategy - User Context Integration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Retrieve Documents from Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Answer": {
      "ai_languageModel": [
        [
          {
            "node": "Answer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Factual": {
      "ai_languageModel": [
        [
          {
            "node": "Factual Strategy - Focus on Precision",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Opinion": {
      "ai_languageModel": [
        [
          {
            "node": "Opinion Strategy - Diverse Perspectives",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Combined Fields": {
      "main": [
        [
          {
            "node": "Query Classification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Analytical": {
      "ai_languageModel": [
        [
          {
            "node": "Analytical Strategy - Comprehensive Coverage",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Contextual": {
      "ai_languageModel": [
        [
          {
            "node": "Contextual Strategy - User Context Integration",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chat Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "Answer",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Concatenate Context": {
      "main": [
        [
          {
            "node": "Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Classification": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Classification": {
      "ai_languageModel": [
        [
          {
            "node": "Query Classification",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set Prompt and Output": {
      "main": [
        [
          {
            "node": "Retrieve Documents from Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Factual Prompt and Output": {
      "main": [
        [
          {
            "node": "Set Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Opinion Prompt and Output": {
      "main": [
        [
          {
            "node": "Set Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Buffer Memory Factual": {
      "ai_memory": [
        [
          {
            "node": "Factual Strategy - Focus on Precision",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Chat Buffer Memory Opinion": {
      "ai_memory": [
        [
          {
            "node": "Opinion Strategy - Diverse Perspectives",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Analytical Prompt and Output": {
      "main": [
        [
          {
            "node": "Set Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contextual Prompt and Output": {
      "main": [
        [
          {
            "node": "Set Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Buffer Memory Analytical": {
      "ai_memory": [
        [
          {
            "node": "Analytical Strategy - Comprehensive Coverage",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Chat Buffer Memory Contextual": {
      "ai_memory": [
        [
          {
            "node": "Contextual Strategy - User Context Integration",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Combined Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Documents from Vector Store": {
      "main": [
        [
          {
            "node": "Concatenate Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Factual Strategy - Focus on Precision": {
      "main": [
        [
          {
            "node": "Factual Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Opinion Strategy - Diverse Perspectives": {
      "main": [
        [
          {
            "node": "Opinion Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analytical Strategy - Comprehensive Coverage": {
      "main": [
        [
          {
            "node": "Analytical Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contextual Strategy - User Context Integration": {
      "main": [
        [
          {
            "node": "Contextual Prompt and Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}