{
  "name": "SUPABASE VECTOR UPDATER",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "https://drive.google.com/drive/folders/1v5w0RN2PDRhr_F8rB3KEqbrac0-FPKj6",
          "mode": "url"
        },
        "event": "=fileCreated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -260,
        -20
      ],
      "id": "a362da37-3d10-4950-9bf6-aa4d779f0cec",
      "name": "Google Drive Trigger",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "gPMQ9BHxuNjYEtM9",
          "name": "Google Drive account"
        }
      },
      "notes": "Add your raw data here to upload it to supabase"
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        20,
        -20
      ],
      "id": "915470f2-b861-4948-83b7-d04723fc2a96",
      "name": "Google Drive",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "gPMQ9BHxuNjYEtM9",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        280,
        -20
      ],
      "id": "4c067d0f-8a02-4a40-88a3-4740bc59659e",
      "name": "Extract from File"
    },
    {
      "parameters": {
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "insta_rag_raw",
          "mode": "list",
          "cachedResultName": "insta_rag_raw"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "id": "={{ $json.id }}",
            "content": "={{ $json.content }}",
            "summary": "={{ $json.summary }}",
            "tags": "={{ $json.tags }}"
          },
          "matchingColumns": [
            "id"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": true,
              "defaultMatch": true,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "content",
              "displayName": "content",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "summary",
              "displayName": "summary",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "tags",
              "displayName": "tags",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "array",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        740,
        -20
      ],
      "id": "83c42f5d-0f03-414f-b753-33b7005144b0",
      "name": "Postgres",
      "credentials": {
        "postgres": {
          "id": "BoIYtkdhWo3hEW7D",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "data",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        500,
        -20
      ],
      "id": "9221637a-3424-4357-a447-fb527302d20e",
      "name": "Split Out"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -260,
        360
      ],
      "id": "56449cca-5fca-4d6a-a47a-330f84e3e8fd",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "insta_rag_embedded",
          "mode": "list",
          "cachedResultName": "insta_rag_embedded"
        },
        "options": {
          "queryName": "match_documents"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1,
      "position": [
        640,
        360
      ],
      "id": "196e34af-b287-49fa-89b0-4d7b6cbee079",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "id": "IVgrGgMtgBB2hKN0",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        620,
        580
      ],
      "id": "e3ad8016-0f59-4ba3-bc14-395ab619e789",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "DxinZvY719O6zGR2",
          "name": "OpenAi Mail"
        }
      }
    },
    {
      "parameters": {
        "jsonMode": "expressionData",
        "jsonData": "={{ $json.content }}",
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "summary",
                "value": "={{ $('Edit Fields').item.json.summary }}"
              },
              {
                "name": "tags",
                "value": "={{ $('Edit Fields').item.json.tags }}"
              }
            ]
          }
        }
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        760,
        580
      ],
      "id": "dc4fc0ab-251a-41db-9d16-5dcfff2d8da3",
      "name": "Default Data Loader"
    },
    {
      "parameters": {
        "chunkOverlap": 100,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        780,
        720
      ],
      "id": "4a2d29cb-d722-42bb-a64d-f912f264914a",
      "name": "Recursive Character Text Splitter"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c7ce1104-f28f-4a12-b41f-1d9a528d895d",
              "name": "id",
              "value": "={{ $json.id }}",
              "type": "number"
            },
            {
              "id": "ab092827-eccb-46d1-a26f-5c9a5bc7a702",
              "name": "content",
              "value": "={{ $json.content }}",
              "type": "string"
            },
            {
              "id": "8e6edbed-b647-412b-adf5-e3eca2d11ae9",
              "name": "summary",
              "value": "={{ $json.summary }}",
              "type": "string"
            },
            {
              "id": "c068b95f-e26c-4e0c-a590-bebf4d4ec192",
              "name": "tags",
              "value": "={{ $json.tags }}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        280,
        360
      ],
      "id": "cb6ce615-b8bd-4df2-a18c-76557b45e258",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "content": "## Use his to upload your CSV to your raw database \n** you can also change the 'Extract from Files' node document type if needed **\n",
        "height": 460,
        "width": 1320
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -360,
        -220
      ],
      "id": "ef2e527a-3a60-4aa3-ad04-930ab03682fd",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT id, content, summary, tags \nFROM insta_rag_raw ",
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        20,
        360
      ],
      "id": "ce09f9d2-998e-4124-b3de-2a23339801b1",
      "name": "Get raw data form supabase",
      "credentials": {
        "postgres": {
          "id": "BoIYtkdhWo3hEW7D",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Create embeddings and upload to vector store\n",
        "height": 640,
        "width": 1480,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -340,
        280
      ],
      "id": "21ada8f5-adb7-4d54-be00-b93ee598be8a",
      "name": "Sticky Note1"
    }
  ],
  "pinData": {},
  "connections": {
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get raw data form supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "main": [
        []
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get raw data form supabase": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "bb8bda49d4a41536be2ec3703dd4202267c5e1712e0469a147c2767ff38876d7"
  },
  "tags": [],
  "id": "nsVOBPV674Kf4bP2"
}