跳到主要内容

Google Trends 工具

Google Trends 工具允许您的 Agent 利用 SerpApi 的 Google Trends API 来检索和分析搜索兴趣数据。这对于了解热门话题、区域搜索兴趣以及搜索词的历史流行度非常有用。

有关 API 详细信息,请参阅此处

SerpApi 缓存查询,因此首次查询速度较慢,而后续相同的查询速度会很快。有时,相关查询将无法工作,而随时间变化的兴趣将可以正常工作。您可以在此处检查您的查询。

设置

要使用此工具,您需要配置对 SerpApi 的 Google Trends API 的访问权限。

SerpApi 获取 API 密钥

然后,将您的 API 密钥设置为 process.env.SERPAPI_API_KEY 或将其作为 apiKey 构造函数参数传入。

使用方法

提示

有关安装集成包的通用说明,请参阅此部分

npm install @langchain/openai @langchain/community @langchain/core
import { SERPGoogleTrendsTool } from "@langchain/community/tools/google_trends";

export async function run() {
const tool = new SERPGoogleTrendsTool();

const res = await tool.invoke("Monster");

console.log(res);
}

API 参考


此页面是否对您有帮助?


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