8
n8n 中文网amn8n.com

使用Supabase向量数据库构建多客户端代理RAG文档处理管道

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 38 个节点。主要使用 Set, Switch, Postgres, Supabase, Aggregate 等节点。 使用Supabase向量数据库构建多客户端代理RAG文档处理管道

前置要求
  • PostgreSQL 数据库连接信息
  • Supabase URL 和 API Key
  • Google Drive API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "393ca9e36a1f81b0f643c72792946a5fe5e49eb4864181ba4032e5a408278263",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "8dcb88e1-3482-41a1-9637-b216806a2613",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        2368,
        736
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "=file_id",
                "value": "={{ $('Set File ID').first().json.file_id }}"
              },
              {
                "name": "file_title",
                "value": "={{ $('Set File ID').first().json.file_title }}"
              }
            ]
          }
        },
        "jsonData": "={{ $json.data || $json.text || $json.concatenated_data }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1
    },
    {
      "id": "e54ed2cc-2648-4e86-8f10-1ae805e09b97",
      "name": "OpenAI 嵌入1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        2128,
        736
      ],
      "parameters": {
        "model": "text-embedding-3-small",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "Wk5dyBYFy6HDwml2",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a3763844-f816-4fb8-bb77-90e4e92a035b",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -384,
        720
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set File ID').item.json.file_id }}"
        },
        "options": {
          "googleFileConversion": {
            "conversion": {
              "docsToFormat": "text/plain"
            }
          }
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "3TalAPza9NdMx3yx",
          "name": "Hugo"
        }
      },
      "executeOnce": true,
      "typeVersion": 3
    },
    {
      "id": "1727e391-12b9-4daf-be02-ed259f203183",
      "name": "文件已创建",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -1584,
        688
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "url",
          "value": "https://drive.google.com/drive/u/0/folders/195OWvKSKZjsdyAIXeqoC9z__QKCRHC8i"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "3TalAPza9NdMx3yx",
          "name": "Hugo"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0ecf4c2d-a8e7-4bc1-9568-4e91761b5975",
      "name": "文件已更新",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -1584,
        848
      ],
      "parameters": {
        "event": "fileUpdated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "url",
          "value": "https://drive.google.com/drive/u/0/folders/195OWvKSKZjsdyAIXeqoC9z__QKCRHC8i"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "3TalAPza9NdMx3yx",
          "name": "Hugo"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "302e3d68-af63-4ca8-8581-4052a2c41a57",
      "name": "提取文档文本",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        880
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "ee1782c4-a0e9-4e2c-91d5-0637f2eb116c",
      "name": "删除旧文档行",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1008,
        704
      ],
      "parameters": {
        "tableId": "documents",
        "operation": "delete",
        "filterType": "string",
        "filterString": "=metadata->>file_id=like.*{{ $json.file_id }}*"
      },
      "credentials": {
        "supabaseApi": {
          "id": "H0kInY9i7zSLf3eu",
          "name": "IDR"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "beb679e2-5d1b-4057-8336-b88a120e14c0",
      "name": "设置文件 ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        864
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "10646eae-ae46-4327-a4dc-9987c2d76173",
              "name": "file_id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "f4536df5-d0b1-4392-bf17-b8137fb31a44",
              "name": "file_type",
              "type": "string",
              "value": "={{ $json.mimeType }}"
            },
            {
              "id": "77d782de-169d-4a46-8a8e-a3831c04d90f",
              "name": "file_title",
              "type": "string",
              "value": "={{ $json.name }}"
            },
            {
              "id": "9bde4d7f-e4f3-4ebd-9338-dce1350f9eab",
              "name": "file_url",
              "type": "string",
              "value": "={{ $json.webViewLink }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6af75b7c-ec0e-4b77-85ba-2a2ee19036c3",
      "name": "提取 PDF 文本",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        400
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "6aa55864-a508-40c9-89d3-688dee81f0b5",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        944,
        576
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "7ce461dd-995b-4bf5-82c2-1c6715eea4d9",
      "name": "字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        2272,
        848
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "88f0b762-bffe-4009-aa05-9731e42eab19",
      "name": "总结",
      "type": "n8n-nodes-base.summarize",
      "position": [
        1152,
        576
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "data",
              "aggregation": "concatenate"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9af99c48-af67-43e2-bc90-652200c29dc4",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        -64,
        688
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "application/pdf"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2ae7faa7-a936-4621-a680-60c512163034",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fc193b06-363b-4699-a97d-e5a850138b0e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "=application/vnd.google-apps.spreadsheet"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b69f5605-0179-4b02-9a32-e34bb085f82d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Set File ID').item.json.file_type }}",
                    "rightValue": "application/vnd.google-apps.document"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": 3
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c0e93762-5c9e-4fd2-a28e-d0d8b4b6b577",
      "name": "插入到 Supabase Vectorstore",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        2288,
        512
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "queryName": "match_documents"
        },
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "H0kInY9i7zSLf3eu",
          "name": "IDR"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a39e26de-40c4-479f-a4a1-0cc694273d10",
      "name": "从 Excel 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        560
      ],
      "parameters": {
        "options": {},
        "operation": "xlsx"
      },
      "typeVersion": 1
    },
    {
      "id": "1bf5cdce-144c-432d-a887-77a380ae9af2",
      "name": "设置模式",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f422e2e0-381c-46ea-8f38-3f58c501d8b9",
              "name": "schema",
              "type": "string",
              "value": "={{ $('Extract from Excel').isExecuted ? $('Extract from Excel').first().json.keys().toJsonString() : $('Extract from CSV').first().json.keys().toJsonString() }}"
            },
            {
              "id": "bb07c71e-5b60-4795-864c-cc3845b6bc46",
              "name": "data",
              "type": "string",
              "value": "={{ $json.concatenated_data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9a3f6aa6-f35d-4a31-bd97-e9dd10bf8b36",
      "name": "从 CSV 提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        512,
        720
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "183a8c77-15b9-4624-ba79-2c6117ab25c0",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1376,
        704
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c8ba6c05-5779-4149-b5a5-c1eb0007f3c0",
      "name": "删除旧数据行",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -848,
        864
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "dataset_id",
              "keyValue": "={{ $('Set File ID').item.json.file_id }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "document_rows",
        "operation": "delete"
      },
      "credentials": {
        "supabaseApi": {
          "id": "H0kInY9i7zSLf3eu",
          "name": "IDR"
        }
      },
      "executeOnce": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "bc67ba0a-5e5c-4c8e-bb0f-3bbea9b1a238",
      "name": "插入文档元数据",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -688,
        720
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "document_metadata",
          "cachedResultName": "document_metadata"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "id": "={{ $('Set File ID').item.json.file_id }}",
            "url": "={{ $('Set File ID').item.json.file_url }}",
            "title": "={{ $('Set File ID').item.json.file_title }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "created_at",
              "type": "dateTime",
              "display": true,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "schema",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "schema",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "credentials": {
        "postgres": {
          "id": "AHpJedehHyZdI0MX",
          "name": "Postgres account - IDR"
        }
      },
      "executeOnce": true,
      "typeVersion": 2.5
    },
    {
      "id": "b73735e9-7a14-4857-80c5-c27a27916a24",
      "name": "插入表行",
      "type": "n8n-nodes-base.postgres",
      "position": [
        992,
        800
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "document_rows",
          "cachedResultName": "document_rows"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "row_data": "={{ $json.toJsonString().replaceAll(/'/g, \"''\") }}",
            "dataset_id": "={{ $('Set File ID').item.json.file_id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "number",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "dataset_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "dataset_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_data",
              "type": "object",
              "display": true,
              "required": false,
              "displayName": "row_data",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "credentials": {
        "postgres": {
          "id": "AHpJedehHyZdI0MX",
          "name": "Postgres account - IDR"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "af533d64-bab2-446a-855c-718551ac0ac3",
      "name": "更新文档元数据模式",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1680,
        560
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "document_metadata",
          "cachedResultName": "document_metadata"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "id": "={{ $('Set File ID').item.json.file_id }}",
            "schema": "={{ $json.schema }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "created_at",
              "type": "dateTime",
              "display": true,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "schema",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "schema",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "credentials": {
        "postgres": {
          "id": "AHpJedehHyZdI0MX",
          "name": "Postgres account - IDR"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "97d27ff3-7682-4119-9ba6-f5303a3a83a6",
      "name": "创建文档元数据表1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -2272,
        768
      ],
      "parameters": {
        "query": "CREATE TABLE {{ $('When chat message received').item.json.chatInput }}_document_metadata (\n    id TEXT PRIMARY KEY,\n    title TEXT,\n    url TEXT,\n    created_at TIMESTAMP DEFAULT NOW(),\n    schema TEXT\n);",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "hPBACn4YwzDXM9a2",
          "name": "Postgres account - Clients"
        }
      },
      "executeOnce": false,
      "typeVersion": 2.5,
      "alwaysOutputData": false
    },
    {
      "id": "57a81189-6b1b-4375-b974-f47732fcf556",
      "name": "创建文档行表(用于表格数据)1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -2080,
        768
      ],
      "parameters": {
        "query": "CREATE TABLE {{ $('When chat message received').item.json.chatInput }}_document_rows (\n    id SERIAL PRIMARY KEY,\n    dataset_id TEXT REFERENCES {{ $('When chat message received').item.json.chatInput }}_document_metadata(id),\n    row_data JSONB  -- Store the actual row data\n);",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "hPBACn4YwzDXM9a2",
          "name": "Postgres account - Clients"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "c792cc00-c762-4f15-8646-ab38880d5abb",
      "name": "创建文档表和匹配函数1",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -2496,
        768
      ],
      "parameters": {
        "query": "-- Create a table to store your documents\nCREATE TABLE {{ $json.chatInput }}_documents (\n  id bigserial primary key,\n  content text, -- corresponds to Document.pageContent\n  metadata jsonb, -- corresponds to Document.metadata\n  embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed\n);\n\n-- Create an index for better performance\nCREATE INDEX {{ $json.chatInput }}_documents_embedding_idx \nON {{ $json.chatInput }}_documents \nUSING ivfflat (embedding vector_cosine_ops);\n\n-- Create a function to search for documents\nCREATE OR REPLACE FUNCTION match_{{ $json.chatInput }}_documents (\n  query_embedding vector(1536),\n  match_count int DEFAULT 10,\n  filter jsonb DEFAULT '{}'\n)\nRETURNS TABLE (\n  id bigint,\n  content text,\n  metadata jsonb,\n  similarity float\n)\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  RETURN QUERY\n  SELECT\n    doc.id,\n    doc.content,\n    doc.metadata,\n    1 - (doc.embedding <=> query_embedding) as similarity\n  FROM {{ $('Chercher nom dernier client').item.json['Dernier client'] }}_documents doc\n  WHERE \n    CASE \n      WHEN filter != '{}' THEN doc.metadata @> filter\n      ELSE TRUE\n    END\n  ORDER BY doc.embedding <=> query_embedding\n  LIMIT match_count;\nEND;\n$$;\n\n-- Grant permissions\nGRANT EXECUTE ON FUNCTION match_{{ $json.chatInput }}_documents TO authenticated;\nGRANT EXECUTE ON FUNCTION match_{{ $json.chatInput }}_documents TO anon;",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "hPBACn4YwzDXM9a2",
          "name": "Postgres account - Clients"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "f47597d0-fbee-4a6b-8c05-c2173c7c677a",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -2704,
        768
      ],
      "webhookId": "d1a1c40a-f780-45de-82cd-7e1edbc030e2",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "f90f3329-854c-4764-a9a4-3260eb2566ef",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2784,
        608
      ],
      "parameters": {
        "width": 928,
        "height": 352,
        "content": "# 阶段 1:特定客户数据库基础设施创建"
      },
      "typeVersion": 1
    },
    {
      "id": "d069eb31-d6d9-44b0-b6ba-d7ad638a228a",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2784,
        1008
      ],
      "parameters": {
        "width": 928,
        "height": 384,
        "content": "### 您需要做的:"
      },
      "typeVersion": 1
    },
    {
      "id": "2b4bd032-c5ed-4dd1-979c-d8d783a46ffe",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        544
      ],
      "parameters": {
        "color": 2,
        "width": 1264,
        "height": 480,
        "content": "# 阶段 2:Google Drive 文件夹监控配置"
      },
      "typeVersion": 1
    },
    {
      "id": "7581238d-621d-46e0-bffd-2d5f79ce419b",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        1072
      ],
      "parameters": {
        "color": 2,
        "width": 1264,
        "height": 752,
        "content": "### 您需要做的:"
      },
      "typeVersion": 1
    },
    {
      "id": "226700d4-3476-4412-b262-fc7cc6eed359",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        352
      ],
      "parameters": {
        "color": 3,
        "width": 1280,
        "height": 672,
        "content": "# 阶段 3:文档处理和内容提取"
      },
      "typeVersion": 1
    },
    {
      "id": "b39dacf6-d438-42ea-baf7-8a107de0d8a5",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        1072
      ],
      "parameters": {
        "color": 3,
        "width": 1280,
        "height": 464,
        "content": "### 系统执行的操作:"
      },
      "typeVersion": 1
    },
    {
      "id": "8e3a496d-a4be-4b86-a605-b9bade310350",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        352
      ],
      "parameters": {
        "color": 4,
        "width": 1072,
        "height": 672,
        "content": "# 阶段 4:数据聚合和模式管理"
      },
      "typeVersion": 1
    },
    {
      "id": "811f442d-439a-473a-9e15-5156860a6d7c",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        1072
      ],
      "parameters": {
        "color": 4,
        "width": 1072,
        "height": 464,
        "content": "### 系统执行的操作:"
      },
      "typeVersion": 1
    },
    {
      "id": "b80cc540-8d1d-49d1-b30f-be387dba08f8",
      "name": "GET 模型",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        352
      ],
      "parameters": {
        "color": 5,
        "width": 848,
        "height": 672,
        "content": "# 阶段 5:高级向量嵌入和文本处理"
      },
      "typeVersion": 1
    },
    {
      "id": "7ccf7914-52a0-439a-8560-e7fa3282d17e",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        1072
      ],
      "parameters": {
        "color": 5,
        "width": 848,
        "height": 432,
        "content": "### 系统执行的操作:"
      },
      "typeVersion": 1
    },
    {
      "id": "b3caa235-e98b-40a6-a65c-5b1da8334e6b",
      "name": "便签 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        464
      ],
      "parameters": {
        "color": 6,
        "width": 928,
        "height": 576,
        "content": "# 阶段 6:特定客户向量数据库存储和工作流完成"
      },
      "typeVersion": 1
    },
    {
      "id": "6e276b1a-8a09-4e6e-9581-5bca83043698",
      "name": "## 1. 创建新的自定义 OpenAI 凭据",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4112,
        640
      ],
      "parameters": {
        "width": 816,
        "height": 336,
        "content": "## 需要更高级的自动化解决方案?联系我们获取自定义企业工作流!"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Extract PDF Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from Excel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from CSV",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Document Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Summarize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize": {
      "main": [
        [
          {
            "node": "Set Schema",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Schema": {
      "main": [
        [
          {
            "node": "Update Schema for Document Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set File ID": {
      "main": [
        [
          {
            "node": "Delete Old Doc Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Created": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Updated": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Set File ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract PDF Text": {
      "main": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from CSV": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert Table Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Excel": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          },
          {
            "node": "Insert Table Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Delete Old Doc Rows": {
      "main": [
        [
          {
            "node": "Delete Old Data Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Old Data Rows": {
      "main": [
        [
          {
            "node": "Insert Document Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Document Text": {
      "main": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Insert Document Metadata": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Create Documents Table and Match Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Document Metadata Table1": {
      "main": [
        [
          {
            "node": "Create Document Rows Table (for Tabular Data)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert into Supabase Vectorstore": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Documents Table and Match Function1": {
      "main": [
        [
          {
            "node": "Create Document Metadata Table1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量38
分类2
节点类型16
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流