但遗憾的是,这并不代表你已经完成了所有准备工作,你需要一个开发者账号,来访问如 GPT-4、Gemini Pro 或 Claude 3 的 API。
API,即应用程序接口,是一套规定了软件组件之间交互的规则。它允许不同的软件系统之间进行通信,交换数据和功能。简单来说,ChatGPT 是 OpenAI 做来给你(人类)使用的界面,GPT-4 API 是 OpenAI 做来给其他程序(机器)使用的界面,n8n 是一个程序,因此在 n8n 系统中接入 AI 需要对应 AI 的 API。
不同的 AI 在注册开发者账号上略有不同,由于涉及比较敏感的内容,本站不教大家如何注册 OpenAI\Google\Claude 的开发者账号。
0.3 什么是 LangChain
LangChain 是一种特殊的大语言模型接口,专门为了将大语言模型接入 n8n 而设计。它可以将各种大语言模型(如 GPT-4、Gemini Pro 或 Claude 3)的 API 进行统一,使得我们在编写 AI 相关的程序时可以方便的使用不同的大语言模型进行各种任务,无需关心模型之间的差异性。简单来说,LangChain 就是在 AI 和程序员之间的一个“翻译器”。
在 n8n 中,LangChain 是一个包含子节点的 AI 节点。在你更换不同的 AI 服务时,可以不用重新设置所有的节点设置,大幅提高我们调试 Workflow 的效率。
1. 节点概览
在 n8n 中,Advaced AI 是一个专门的 node 类别,其下有多种不同的 AI 类型。在这里,我们会详细介绍两个最常用的 AI 节点,让你掌握 AI 在 n8n 中的接入逻辑。
大部分的 n8n AI 节点都在介绍里写明了自己的用处是什么,你还可以点击 AI Templates 从官方社区下载别人已经组合好的 Chain。这些部分在你理解了 n8n 的 AI 接入逻辑后,只需自己稍微探索就能学会。
Documentation for the Agent node in n8n, a workflow automation platform. Includes details of operations and configuration, and links to examples and credentials information.
Tools Agent
Memory/Tool
用自然语言操作一个工具,比如你可以用它来让 AI 算数,因为对于大语言模型来说,计算器就是一个工具。该模式不支持上下文记忆。
Documentation for the Agent node in n8n, a workflow automation platform. Includes details of operations and configuration, and links to examples and credentials information.
Documentation for the Agent node in n8n, a workflow automation platform. Includes details of operations and configuration, and links to examples and credentials information.
Plan and Execute Agent
Tool
用于通过自然语言调用工具的模型,允许连接多个工具,由 AI 自行计划使用哪些工具以及如何组合。
ㅤ
ReAct Agent
Memory/Tool
Plan and Execute Agent 的进阶版本,如果你用过 ChatGPT Plus 更好理解。AI 会根据你的自然语言任务,选择合适的工具执行任务,然后再检查工具返回的结果,如果结果不正确,就再试试其他方法。该模式可能会对 AI 发起多次请求。
Documentation for the Agent node in n8n, a workflow automation platform. Includes details of operations and configuration, and links to examples and credentials information.
Documentation for the Agent node in n8n, a workflow automation platform. Includes details of operations and configuration, and links to examples and credentials information.