Skip to main content

Google 趋势工具

¥Google Trends Tool

Google Trends 工具允许你的代理利用 SerpApi 的 Google Trends API 检索和分析搜索兴趣数据。这可用于了解热门话题、区域搜索兴趣以及搜索词的历史热门程度。

¥The Google Trends Tool allows your agent to utilize the Google Trends API from SerpApi to retrieve and analyze search interest data. This can be useful for understanding trending topics, regional search interest, and historical popularity of search terms.

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

¥For API details see here

SerpApi 会缓存查询,因此第一个查询会较慢,而后续相同的查询会很快。有时,相关查询会失败,但兴趣查询可以随时间变化。你可以检查你的查询 此处

¥SerpApi caches queries, so the first query will be slower while subsequent identical queries will be fast. Occasionally, related queries will not work while interest over time will be fine. You can check your query here.

设置

¥Setup

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

¥To use this tool, you will need to configure access to the Google Trends API from SerpApi.

SerpApi 获取 API 密钥

¥Get an API key from SerpApi

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

¥Then, set your API key as process.env.SERPAPI_API_KEY or pass it in as an apiKey constructor argument.

用法

¥Usage

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 Reference:

¥Related