SerpApi Google 搜索工具
SerpApiGoogleSearchTool
Section titled “SerpApiGoogleSearchTool”使用 SerpApiGoogleSearchTool 通过 SerpApi 运行 Google 搜索并返回结构化结果。需要 SerpApi API key。
uv add crewai-tools[serpapi]SERPAPI_API_KEY(必需):SerpApi 的 API key。可在 https://serpapi.com/ 创建(有免费层)。
from crewai import Agent, Task, Crewfrom crewai_tools import SerpApiGoogleSearchTool
tool = SerpApiGoogleSearchTool()
agent = Agent( role="研究员", goal="使用 Google 搜索回答问题", backstory="搜索专家", tools=[tool], verbose=True,)
task = Task( description="搜索最新的 CrewAI 发布版本", expected_output="包含标题和链接的相关结果简明列表", agent=agent,)
crew = Crew(agents=[agent], tasks=[task])result = crew.kickoff()- 请在环境中设置
SERPAPI_API_KEY。可在 https://serpapi.com/ 创建密钥。 - 另见通过 SerpApi 的 Google Shopping:
/zh/tools/search-research/serpapi-googleshoppingtool
search_query(str, required):Google 查询。location(str, optional):地理位置参数。
- 此工具封装了 SerpApi,并返回结构化搜索结果。