以编程方式使用文档

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

Zapier 自然语言操作 通过自然语言 API 接口让您访问 Zapier 平台上的 5k+ 应用和 20k+ 操作。

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 查询和执行这些操作。

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

服务端(API Key):用于快速上手、测试以及 LangChain 仅使用开发者 Zapier 账户中公开的操作的生产场景(并将使用开发者在 Zapier.com 上关联的账户)

面向用户(OAuth):用于部署面向最终用户的应用程序且 LangChain 需要访问用户在 Zapier.com 上公开的操作和关联账户的生产场景

通过环境变量(ZAPIER_NLA_OAUTH_ACCESS_TOKEN or ZAPIER_NLA_API_KEY)或参考 API 参考文档中的 params 参数来附加 NLA 凭证 ZapierNLAWrapper.

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

以下示例演示如何将 Zapier 集成作为 Agent 使用:

npm install @langchain/openai @langchain/core
  initializeAgentExecutorWithOptions,
  ZapierToolKit,
} from "@langchain/classic/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}`);

相关