Skip to main content

集成 Zapier NLA 的代理

¥Agent with Zapier NLA Integration

danger

此模块已被弃用,不再受支持。以下文档不适用于 0.2.0 或更高版本。

¥This module has been deprecated and is no longer supported. The documentation below will not work in versions 0.2.0 or later.

完整文档在此:https://nla.zapier.com/start/

¥Full docs here: https://nla.zapier.com/start/

Zapier 自然语言操作 (NLA) 让你通过自然语言 API 接口访问 Zapier 平台上的 5000+ 个应用和 20000+ 个操作。

¥Zapier Natural Language Actions gives you access to the 5k+ apps and 20k+ actions on Zapier's platform through a natural language API interface.

NLA 支持 Gmail、Salesforce、Trello、Slack、Asana、HubSpot、Google Sheets、Microsoft Teams 等数千款应用:https://zapier.com/apps

¥NLA supports apps like Gmail, Salesforce, Trello, Slack, Asana, HubSpot, Google Sheets, Microsoft Teams, and thousands more apps: https://zapier.com/apps

Zapier NLA 处理所有底层 API 授权和自然语言翻译 --> 底层 API 调用 --> 返回 LLM 的简化输出。关键思想是你或你的用户通过类似 OAuth 的设置窗口公开一组操作,然后你可以通过 REST API 查询和执行这些操作。

¥Zapier NLA handles ALL the underlying API auth and translation from natural language --> underlying API call --> return simplified output for LLMs. The key idea is you, or your users, expose a set of actions via an oauth-like setup window, which you can then query and execute via a REST API.

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

¥NLA offers both API Key and OAuth for signing NLA API requests.

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

¥Server-side (API Key): for quickly getting started, testing, and production scenarios where LangChain will only use actions exposed in the developer's Zapier account (and will use the developer's connected accounts on Zapier.com)

面向用户 (Oauth):适用于生产场景,即你正在部署面向终端用户的应用,并且 LangChain 需要访问终端用户在 Zapier.com 上公开的操作和关联的账户。

¥User-facing (Oauth): for production scenarios where you are deploying an end-user facing application and LangChain needs access to end-user's exposed actions and connected accounts on Zapier.com

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

¥Attach NLA credentials via either an environment variable (ZAPIER_NLA_OAUTH_ACCESS_TOKEN or ZAPIER_NLA_API_KEY) or refer to the params argument in the API reference for ZapierNLAWrapper.

查看 授权文档 了解更多详情。

¥Review auth docs for more details.

以下示例演示了如何将 Zapier 集成用作代理:

¥The example below demonstrates how to use the Zapier integration as an 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}`);

¥Related