SerpApi Google 购物工具
SerpApiGoogleShoppingTool
Section titled “SerpApiGoogleShoppingTool”使用 SerpApiGoogleShoppingTool 通过 SerpApi 查询 Google Shopping 并返回面向商品的结果。
uv add crewai-tools[serpapi]SERPAPI_API_KEY(必需):SerpApi 的 API key。可在 https://serpapi.com/ 创建(有免费层)。
from crewai import Agent, Task, Crewfrom crewai_tools import SerpApiGoogleShoppingTool
tool = SerpApiGoogleShoppingTool()
agent = Agent( role="购物研究员", goal="查找相关商品", backstory="商品搜索专家", tools=[tool], verbose=True,)
task = Task( description="搜索 Google Shopping 中的 'wireless noise-canceling headphones'", expected_output="带标题和链接的相关商品列表", agent=agent,)
crew = Crew(agents=[agent], tasks=[task])result = crew.kickoff()- 请在环境中设置
SERPAPI_API_KEY。可在 https://serpapi.com/ 创建密钥。 - 另见通过 SerpApi 的 Google Web Search:
/zh/tools/search-research/serpapi-googlesearchtool
search_query(str, required):商品搜索查询。location(str, optional):地理位置参数。