跳到主要内容

Agent with Zapier NLA Integration

危险

此模块已被弃用,不再受支持。以下文档在 0.2.0 或更高版本中将无法使用。

完整文档请见此处: https://nla.zapier.com/start/

Zapier Natural Language Actions(自然语言操作) 让您通过自然语言 API 接口访问 Zapier 平台上的 5000 多个应用和 20000 多个操作。

NLA 支持 Gmail、Salesforce、Trello、Slack、Asana、HubSpot、Google Sheets、Microsoft Teams 以及数千个其他应用,例如:https://zapier.com/apps

Zapier NLA 处理所有底层的 API 身份验证和从自然语言到底层 API 调用的转换,并返回 LLM 的简化输出。关键思想是您或您的用户通过类似 OAuth 的设置窗口公开一组操作,然后您可以通过 REST API 查询和执行这些操作。

NLA 为签名 NLA API 请求提供 API 密钥和 OAuth 两种方式。

服务器端(API 密钥):适用于快速入门、测试以及生产场景,在这些场景中,LangChain 将仅使用开发者 Zapier 帐户中公开的操作(并将使用开发者在 Zapier.com 上连接的帐户)。

用户端(OAuth):适用于您部署面向最终用户的应用程序的生产场景,并且 LangChain 需要访问最终用户在 Zapier.com 上公开的操作和连接的帐户。

通过环境变量 (ZAPIER_NLA_OAUTH_ACCESS_TOKENZAPIER_NLA_API_KEY) 附加 NLA 凭据,或参阅 ZapierNLAWrapper 的 API 参考中的 params 参数。

查看 身份验证文档 了解更多详情。

以下示例演示了如何将 Zapier 集成用作 Agent

npm install @langchain/openai @langchain/core
import { OpenAI } from "@langchain/openai";
import { ZapierNLAWrapper } from "langchain/tools";
import {
initializeAgentExecutorWithOptions,
ZapierToolKit,
} from "langchain/agents";

const model = new OpenAI({ temperature: 0 });
const zapier = new ZapierNLAWrapper();
const toolkit = await ZapierToolKit.fromZapierNLAWrapper(zapier);

const executor = await initializeAgentExecutorWithOptions(
toolkit.tools,
model,
{
agentType: "zero-shot-react-description",
verbose: true,
}
);
console.log("Loaded agent.");

const input = `Summarize the last email I received regarding Silicon Valley Bank. Send the summary to the #test-zapier Slack channel.`;

console.log(`Executing with input "${input}"...`);

const result = await executor.invoke({ input });

console.log(`Got output ${result.output}`);

此页面是否对您有帮助?


您也可以留下详细的反馈 在 GitHub 上.