{
  "name": "ADIK-03 RAG Q&A (Qdrant + HF Embeddings)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "rag-qa",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "trigger-03",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "adik-rag-qa"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" },
              "conditions": [{ "id": "1", "leftValue": "={{ $json.body.action }}", "rightValue": "ingest", "operator": { "type": "string", "operation": "equals" } }],
              "combinator": "and" }, "renameOutput": true, "outputKey": "ingest" },
            { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" },
              "conditions": [{ "id": "2", "leftValue": "={{ $json.body.action }}", "rightValue": "query", "operator": { "type": "string", "operation": "equals" } }],
              "combinator": "and" }, "renameOutput": true, "outputKey": "query" }
          ]
        },
        "options": {}
      },
      "id": "switch",
      "name": "Switch Action",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:7860/api/langchain/rag/ingest",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"collection\": {{ JSON.stringify($json.body.collection || 'adik-default') }},\n  \"texts\": {{ JSON.stringify($json.body.texts || []) }},\n  \"metadatas\": {{ JSON.stringify($json.body.metadatas || []) }}\n}",
        "options": {}
      },
      "id": "ingest",
      "name": "Ingest to Qdrant",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [680, 220]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:7860/api/langchain/rag/query",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"collection\": {{ JSON.stringify($json.body.collection || 'adik-default') }},\n  \"query\": {{ JSON.stringify($json.body.query) }},\n  \"k\": {{ $json.body.k || 4 }},\n  \"answer_with_llm\": true\n}",
        "options": {}
      },
      "id": "query",
      "name": "Query RAG",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [680, 380]
    }
  ],
  "connections": {
    "Webhook":          { "main": [[{ "node": "Switch Action", "type": "main", "index": 0 }]] },
    "Switch Action":    { "main": [
                          [{ "node": "Ingest to Qdrant", "type": "main", "index": 0 }],
                          [{ "node": "Query RAG", "type": "main", "index": 0 }]
                        ]}
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "tags": [{ "name": "adik-os" }, { "name": "rag" }]
}
