8
n8n 中文网amn8n.com

使用Lookio从CSV运行批量RAG查询

中级

这是一个Document Extraction, AI RAG领域的自动化工作流,包含 14 个节点。主要使用 If, Set, Form, SplitOut, Aggregate 等节点。 使用Lookio从CSV运行批量RAG查询

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "nodes": [
    {
      "id": "67633966-e2e7-4440-82df-1572d6db8521",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1344,
        -224
      ],
      "webhookId": "4d820714-9a11-4df8-b532-941f06d85ee4",
      "parameters": {
        "options": {
          "respondWithOptions": {
            "values": {
              "respondWith": "redirect"
            }
          }
        },
        "formTitle": "Bulk Lookio queries",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "CSV",
              "multipleFiles": false,
              "requiredField": true,
              "acceptFileTypes": ".csv"
            }
          ]
        },
        "formDescription": "Import a CSV with a column named \"Query\" to have your Lookio assistant populate answers in a new \"Response\" column."
      },
      "typeVersion": 2.3
    },
    {
      "id": "1310a771-7449-4462-8620-7edfdff0216c",
      "name": "有效查询列?",
      "type": "n8n-nodes-base.if",
      "position": [
        -672,
        -224
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "75d079ba-b720-4e95-8e65-b8321e9974d8",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.data[0].Query }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "019738fb-b4cd-4737-9f38-2774e5ec9a2f",
      "name": "错误消息",
      "type": "n8n-nodes-base.form",
      "position": [
        -448,
        -160
      ],
      "webhookId": "be644271-97c5-4a2d-a9a8-fa6f0f516ef4",
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Error",
        "completionMessage": "No \"query\" column has been found"
      },
      "typeVersion": 2.3
    },
    {
      "id": "0e951a6c-0746-4e1a-b302-36a6831af61e",
      "name": "隔离查询列",
      "type": "n8n-nodes-base.set",
      "position": [
        -224,
        -352
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "082751fc-44cb-490e-8ecc-f24105d38209",
              "name": "Query",
              "type": "string",
              "value": "={{ $json.Query }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e3115cce-3534-44a3-af33-0142db6dcae4",
      "name": "Lookio API 调用",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        368,
        -64
      ],
      "parameters": {
        "url": "=https://api.lookio.app/webhook/query",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $json.Query }}"
            },
            {
              "name": "assistant_id",
              "value": "<your-assistant-id>"
            },
            {
              "name": "query_mode",
              "value": "flash"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "api_key",
              "value": "<your-lookio-api-key>"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "74d3c3b1-5e1b-437a-826b-d8ac00befa12",
      "name": "准备输出",
      "type": "n8n-nodes-base.set",
      "position": [
        640,
        32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c1a5c6c0-53d9-484d-a53d-da887e87e019",
              "name": "Query",
              "type": "string",
              "value": "={{ $('Loop Over Queries').item.json.Query }}"
            },
            {
              "id": "244e8abc-c188-4171-80fe-6af3e0871dcd",
              "name": "Response",
              "type": "string",
              "value": "={{ $json.Output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f20125d3-319b-4fbe-a9b5-43b661209375",
      "name": "生成增强 CSV",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        224,
        -512
      ],
      "parameters": {
        "options": {
          "fileName": "Lookio bulk result"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "6fd86367-fbc4-400a-82e7-1692713701e0",
      "name": "表单结束和文件下载",
      "type": "n8n-nodes-base.form",
      "position": [
        448,
        -512
      ],
      "webhookId": "632a77c4-a4fc-4b30-9443-dbacd7dfc5cd",
      "parameters": {
        "options": {},
        "operation": "completion",
        "respondWith": "returnBinary",
        "completionTitle": "Your enriched file is ready",
        "completionMessage": "A new column \"Response\" has been added and contains the result from your Lookio Assistant"
      },
      "typeVersion": 2.3
    },
    {
      "id": "01e59eba-4f02-4c67-8906-a86733731a83",
      "name": "遍历查询",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        0,
        -352
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "57584832-b58f-453c-b549-b70781441d88",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -448,
        -352
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data"
      },
      "typeVersion": 1
    },
    {
      "id": "fedc6b1b-56a9-4698-8ade-3b262f9043b6",
      "name": "聚合行",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -896,
        -224
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "eff9c493-a49d-4535-b8dd-155da490cd82",
      "name": "提取所有行",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1120,
        -224
      ],
      "parameters": {
        "options": {},
        "binaryPropertyName": "CSV"
      },
      "typeVersion": 1
    },
    {
      "id": "ee9afc4b-6377-4eec-87ba-8907b319ec26",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2016,
        -560
      ],
      "parameters": {
        "width": 592,
        "height": 528,
        "content": "# CSV 批量 RAG 查询与 Lookio"
      },
      "typeVersion": 1
    },
    {
      "id": "ae680945-b8e8-4e83-bf3f-8bad9514cb1f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -272
      ],
      "parameters": {
        "color": 6,
        "width": 336,
        "height": 368,
        "content": "## Lookio 用于知识检索"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "Isolate the Query column",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate rows": {
      "main": [
        [
          {
            "node": "Valid Query column?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare output": {
      "main": [
        [
          {
            "node": "Loop Over Queries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookio API call": {
      "main": [
        [
          {
            "node": "Prepare output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract all rows": {
      "main": [
        [
          {
            "node": "Aggregate rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Queries": {
      "main": [
        [
          {
            "node": "Generate enriched CSV",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Lookio API call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Extract all rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Valid Query column?": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate enriched CSV": {
      "main": [
        [
          {
            "node": "Form ending and file download",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Isolate the Query column": {
      "main": [
        [
          {
            "node": "Loop Over Queries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 文档提取, AI RAG 检索增强

需要付费吗?

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

工作流信息
难度等级
中级
节点数量14
分类2
节点类型11
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Guillaume Duvernay

Guillaume Duvernay

@duv

AI and automation expert

外部链接
在 n8n.io 查看

分享此工作流