先决条件
以下示例需要agentql 库和一个 API 令牌,您可以在 AgentQL 获取。
示例
下面的 Agent 将打开一个网页浏览器并抓取页面上的所有文本。cookbook/tools/agentql_tools.py
AgentQL 将打开一个浏览器实例(请勿关闭),并抓取该网站上的内容。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
agentql 库和一个 API 令牌,您可以在 AgentQL 获取。
pip install -U agentql
export AGENTQL_API_KEY=***
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)
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
api_key | str | None | AgentQL 的 API 密钥 |
scrape | bool | True | 是否使用抓取文本工具 |
agentql_query | str | None | 自定义 AgentQL 查询 |
| 函数 | 描述 |
|---|---|
scrape_website | 用于抓取网页上的所有文本 |
custom_scrape_website | 使用自定义 agentql_query 抓取网页内容 |