AgentQLTools 允许 Agent 使用 AgentQL API 来浏览和抓取网站。

先决条件

以下示例需要 agentql 库和一个 API 令牌,您可以在 AgentQL 获取。

pip install -U agentql
export AGENTQL_API_KEY=***

示例

下面的 Agent 将打开一个网页浏览器并抓取页面上的所有文本。

cookbook/tools/agentql_tools.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.agentql import AgentQLTools

agent = Agent(
    model=OpenAIChat(id="gpt-4o"), tools=[AgentQLTools()], show_tool_calls=True
)

agent.print_response("https://docs.agno.com/introduction", markdown=True)

AgentQL 将打开一个浏览器实例(请勿关闭),并抓取该网站上的内容。

Toolkit 参数

参数类型默认值描述
api_keystrNoneAgentQL 的 API 密钥
scrapeboolTrue是否使用抓取文本工具
agentql_querystrNone自定义 AgentQL 查询

Toolkit 函数

函数描述
scrape_website用于抓取网页上的所有文本
custom_scrape_website使用自定义 agentql_query 抓取网页内容

开发者资源