8
n8n 中文网amn8n.com

使用 RAG 和 Google Gemini API 的 IPL 板球规则问答聊天机器人

高级

这是一个Engineering, Multimodal AI领域的自动化工作流,包含 24 个节点。主要使用 HttpRequest, ManualTrigger, Agent, ChatTrigger, LmChatGoogleGemini 等节点。 基于 RAG 和 Google Gemini API 的 IPL 板球规则问答聊天机器人

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "CkgF5zRqCL4BS6I5",
  "meta": {
    "instanceId": "5c50f3d58b333c0490a31213f0ec76116e02346dcdd9088649ba9dd6fbe45ca1",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 RAG 和 Google Gemini API 的 IPL 板球规则问答聊天机器人",
  "tags": [],
  "nodes": [
    {
      "id": "4c32f558-efff-4eff-b714-202c7419a96c",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1216,
        192
      ],
      "webhookId": "4df707a8-70c8-4fab-a970-a97ce7d7594f",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "352186bb-07d1-4d7d-9f0f-b57e0880fc11",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1008,
        64
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a cricket expert. \n\nYou are tasked with answering questions on ipl cricket queries. Information should only be referred to and provided if it is provided explicitly in the data base to you. Your goal is to provide accurate information based on this information.\n\nIf information is not provided to you explicitly or if you can not answer the question using the provided information, say \"Sorry I donot know\""
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "15f7fbdc-ab77-4007-9a8e-8ddbe881d984",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -784,
        336
      ],
      "parameters": {
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "dc61d50a-fdd8-4a21-974f-33aa8aab5c0a",
      "name": "简单向量存储",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        -720,
        176
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 10,
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        },
        "toolDescription": "This is a repository of ipl cricket rules and international cricket rules"
      },
      "typeVersion": 1.3
    },
    {
      "id": "69f8782c-c5d2-4693-bc00-a2ab58c61e08",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -944,
        336
      ],
      "parameters": {
        "options": {
          "topP": 0.3
        }
      },
      "credentials": {
        "googlePalmApi": {
          "id": "3f4CCF4BMZnEfG6y",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "33d9a2a4-6f13-4cbe-a3b3-19f3d0b7d6a1",
      "name": "嵌入 Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        -608,
        320
      ],
      "parameters": {},
      "credentials": {
        "googlePalmApi": {
          "id": "3f4CCF4BMZnEfG6y",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "05bbad6c-877c-4d6d-90e1-6c82d6560ae2",
      "name": "简单向量存储1",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        -896,
        -544
      ],
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "34948452-2e69-40cc-9b86-b78500873aab",
      "name": "嵌入 Google Gemini1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        -896,
        -320
      ],
      "parameters": {},
      "credentials": {
        "googlePalmApi": {
          "id": "3f4CCF4BMZnEfG6y",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d6b2871c-78c6-4785-8913-262eb2364f7d",
      "name": "默认数据加载器",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        -720,
        -400
      ],
      "parameters": {
        "options": {},
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "6818e50a-ecc1-40e5-aac9-9d38fc85d3ec",
      "name": "递归字符文本分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        -704,
        -256
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "48da425a-c41f-4301-b4a7-df00f604ba5b",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1040,
        -448
      ],
      "parameters": {
        "url": "https://documents.iplt20.com/bcci/documents/1742707993986_Match_Playing_Conditions.pdf",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "3fc9062b-fdef-421d-a7a3-d348c83cb51c",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1232,
        -448
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "60491e32-d0c1-4e4a-922f-8ce976b481d1",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2576,
        -48
      ],
      "parameters": {
        "color": 6,
        "width": 2144,
        "height": 624,
        "content": "## 步骤 2"
      },
      "typeVersion": 1
    },
    {
      "id": "1909411f-90b0-4cd5-823a-39f4f918cc5e",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2576,
        -624
      ],
      "parameters": {
        "width": 2160,
        "height": 544,
        "content": "## 步骤 1"
      },
      "typeVersion": 1
    },
    {
      "id": "63e38b73-3e30-47d7-86bb-afa2ad92dc2b",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2576,
        -768
      ],
      "parameters": {
        "color": 5,
        "width": 2160,
        "height": 128,
        "content": "## 此工作流程包含 2 个主要步骤"
      },
      "typeVersion": 1
    },
    {
      "id": "f45e2852-88a8-4f70-a124-01f2b06d9a19",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1232,
        -544
      ],
      "parameters": {
        "color": 3,
        "width": 278,
        "height": 80,
        "content": "## 步骤 1.1"
      },
      "typeVersion": 1
    },
    {
      "id": "0b72e856-23c6-42c2-860e-8f761f861d95",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -304
      ],
      "parameters": {
        "color": 3,
        "width": 166,
        "height": 128,
        "content": "## 步骤 1.2"
      },
      "typeVersion": 1
    },
    {
      "id": "96c343b7-3961-49c1-97e0-35b4eee90d78",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1088,
        -240
      ],
      "parameters": {
        "color": 3,
        "width": 150,
        "height": 80,
        "content": "## 步骤 1.4"
      },
      "typeVersion": 1
    },
    {
      "id": "f78516ba-4b17-4e48-9450-ba5d7cb123f1",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -544
      ],
      "parameters": {
        "color": 3,
        "width": 150,
        "height": 80,
        "content": "## 步骤 1.5"
      },
      "typeVersion": 1
    },
    {
      "id": "b97281a4-6b1f-41a1-9a1e-c48be5a6854c",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1248,
        96
      ],
      "parameters": {
        "color": 4,
        "width": 160,
        "height": 80,
        "content": "## 步骤 2.1"
      },
      "typeVersion": 1
    },
    {
      "id": "a8de0dce-eaa0-441d-b050-5374741f3b5f",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        464
      ],
      "parameters": {
        "color": 4,
        "width": 160,
        "height": 80,
        "content": "## 步骤 2.4"
      },
      "typeVersion": 1
    },
    {
      "id": "1f405862-c83e-4687-b919-3e128bcd2073",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        64
      ],
      "parameters": {
        "color": 4,
        "width": 160,
        "height": 80,
        "content": "## 步骤 2.3"
      },
      "typeVersion": 1
    },
    {
      "id": "dfb4cbe2-f6b0-45c4-bda7-d5f33a3b8e5f",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        464
      ],
      "parameters": {
        "color": 4,
        "width": 160,
        "height": 80,
        "content": "## 步骤 2.2"
      },
      "typeVersion": 1
    },
    {
      "id": "c5cfbb0b-2d09-40b8-ba18-5c4028d8a556",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 160,
        "height": 80,
        "content": "## 步骤 2.5"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "98c130a5-eef0-4246-8a95-88a29c4e8ce6",
  "connections": {
    "48da425a-c41f-4301-b4a7-df00f604ba5b": {
      "main": [
        [
          {
            "node": "05bbad6c-877c-4d6d-90e1-6c82d6560ae2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "15f7fbdc-ab77-4007-9a8e-8ddbe881d984": {
      "ai_memory": [
        [
          {
            "node": "352186bb-07d1-4d7d-9f0f-b57e0880fc11",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "d6b2871c-78c6-4785-8913-262eb2364f7d": {
      "ai_document": [
        [
          {
            "node": "05bbad6c-877c-4d6d-90e1-6c82d6560ae2",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "dc61d50a-fdd8-4a21-974f-33aa8aab5c0a": {
      "ai_tool": [
        [
          {
            "node": "352186bb-07d1-4d7d-9f0f-b57e0880fc11",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "33d9a2a4-6f13-4cbe-a3b3-19f3d0b7d6a1": {
      "ai_embedding": [
        [
          {
            "node": "dc61d50a-fdd8-4a21-974f-33aa8aab5c0a",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "69f8782c-c5d2-4693-bc00-a2ab58c61e08": {
      "ai_languageModel": [
        [
          {
            "node": "352186bb-07d1-4d7d-9f0f-b57e0880fc11",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "34948452-2e69-40cc-9b86-b78500873aab": {
      "ai_embedding": [
        [
          {
            "node": "05bbad6c-877c-4d6d-90e1-6c82d6560ae2",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "4c32f558-efff-4eff-b714-202c7419a96c": {
      "main": [
        [
          {
            "node": "352186bb-07d1-4d7d-9f0f-b57e0880fc11",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6818e50a-ecc1-40e5-aac9-9d38fc85d3ec": {
      "ai_textSplitter": [
        [
          {
            "node": "d6b2871c-78c6-4785-8913-262eb2364f7d",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "3fc9062b-fdef-421d-a7a3-d348c83cb51c": {
      "main": [
        [
          {
            "node": "48da425a-c41f-4301-b4a7-df00f604ba5b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 工程, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34