Skip to main content

Tavily Search API plugin for NoneBot2

Project description

nonebot-plugin-tavily

基于 Tavily API 的 NoneBot2 插件,提供强大的实时联网搜索、内容提取和智能抓取能力。

该插件既可以作为普通的 NoneBot 插件独立使用,也可以作为 Tool 供其他 Agent 插件(如 nonebot-plugin-dify)调用。

💿 安装

使用 nb-cli 安装

nb plugin install nonebot-plugin-tavily

使用 pip 安装

pip install nonebot-plugin-tavily

⚙️ 配置

.env 文件中添加以下配置:

# Tavily API 密钥 (必填)
TAVILY_API_KEY=tvly-xxxxxxxxxxxxxxxx

# 默认搜索深度: basic (快速) / advanced (深度)
TAVILY_DEFAULT_DEPTH=basic

# 默认最大抓取页面数
TAVILY_MAX_BREADTH=10

# 搜索返回结果数量
TAVILY_MAX_RESULTS=5

# 搜索时间范围: day/week/month/year (留空不限制)
TAVILY_TIME_RANGE=

# 简单模式: 仅输出内容,不含标题和 URL
TAVILY_SIMPLE_MODE=false

# 内容截断长度
TAVILY_SEARCH_TRUNCATE=200   # 搜索结果
TAVILY_EXTRACT_TRUNCATE=2000 # 提取内容
TAVILY_CRAWL_TRUNCATE=150    # 抓取预览

🎉 使用指南

1. 联网搜索 (/search)

获取实时的网络搜索结果。

/search <关键词> [--depth basic|advanced]

示例:

/search "NoneBot2 最新版本" --depth advanced

2. 内容提取 (/extract)

提取指定 URL 的核心正文内容,自动去除广告和无关信息。

/extract <URL> [--depth basic|advanced]

示例:

/extract "https://example.com/article" --depth advanced

3. 智能抓取 (/crawl)

深度抓取网站内容,支持自然语言指令控制抓取目标。

/crawl <URL> [--instructions "指令内容"] [--max_breadth <数量>]

示例:

/crawl "https://company.com" --instructions "查找联系邮箱和地址"

🛠️ 作为工具集成

本插件基于 Alconna 构建,命令参数具有强类型定义,非常适合作为 Agent 工具使用。

如果你使用的是支持工具调用的插件(如 nonebot-plugin-dify),只需将以下命令加入工具白名单即可:

  • search
  • extract
  • crawl

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_tavily-0.1.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_tavily-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_tavily-0.1.0.tar.gz.

File metadata

  • Download URL: nonebot_plugin_tavily-0.1.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nonebot_plugin_tavily-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f50d99ee8d45357bb5e62836339f9f29d74c732ba3a7a0a0fec3b203a863f8f4
MD5 2de781143a267fa12b272736143e27e4
BLAKE2b-256 d1c908619bba8f217d8cd2ad71aed350ba7aee21a5a798058b53488087358ae3

See more details on using hashes here.

File details

Details for the file nonebot_plugin_tavily-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_tavily-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d347298af4b5f370a172dd23d82306cab4074031f25772f2a89075d676b76d4
MD5 0a873544b1682e7c2376baadc972cfe9
BLAKE2b-256 a429df3b110297dfe7f9ba826b91be7cfd4690402168221c0a8128e99a433451

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page