Skip to content

Commit 912e4df

Browse files
author
Tavily PR Agent
committed
feat: add Tavily as parallel web search channel alongside Exa
1 parent e178470 commit 912e4df

File tree

6 files changed

+84
-3
lines changed

6 files changed

+84
-3
lines changed

agent_reach/channels/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .rss import RSSChannel
1616
from .bilibili import BilibiliChannel
1717
from .exa_search import ExaSearchChannel
18+
from .tavily_search import TavilySearchChannel
1819
from .xiaohongshu import XiaoHongShuChannel
1920
from .douyin import DouyinChannel
2021
from .linkedin import LinkedInChannel
@@ -41,6 +42,7 @@
4142
XueqiuChannel(),
4243
RSSChannel(),
4344
ExaSearchChannel(),
45+
TavilySearchChannel(),
4446
WebChannel(),
4547
]
4648

agent_reach/channels/reddit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class RedditChannel(Channel):
1010
name = "reddit"
1111
description = "Reddit 帖子和评论"
12-
backends = ["rdt-cli"]
12+
backends = ["rdt-cli", "Exa", "Tavily"]
1313
tier = 0
1414

1515
def can_handle(self, url: str) -> bool:
@@ -27,5 +27,6 @@ def check(self, config=None):
2727
"需要安装 rdt-cli:\n"
2828
" pipx install rdt-cli\n"
2929
"或:\n"
30-
" uv tool install rdt-cli"
30+
" uv tool install rdt-cli\n"
31+
"搜索也可使用 Exa(免费)或 Tavily(需 API Key)作为替代"
3132
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- coding: utf-8 -*-
2+
"""Tavily Search — API-based web search via tavily-python."""
3+
4+
import os
5+
from .base import Channel
6+
7+
8+
class TavilySearchChannel(Channel):
9+
name = "tavily_search"
10+
description = "全网搜索(Tavily API)"
11+
backends = ["Tavily API"]
12+
tier = 2
13+
14+
def can_handle(self, url: str) -> bool:
15+
return False # Search-only channel
16+
17+
def check(self, config=None):
18+
# Check for tavily-python
19+
try:
20+
import tavily # noqa: F401
21+
except ImportError:
22+
return "off", (
23+
"需要安装 tavily-python:\n"
24+
" pip install tavily-python"
25+
)
26+
27+
# Check for API key via config or env
28+
api_key = None
29+
if config:
30+
api_key = config.get("tavily_api_key")
31+
if not api_key:
32+
api_key = os.environ.get("TAVILY_API_KEY")
33+
34+
if not api_key:
35+
return "off", (
36+
"需要 TAVILY_API_KEY。获取:\n"
37+
" 1. 访问 https://app.tavily.com 注册(每月 1000 次免费)\n"
38+
" 2. agent-reach configure tavily_api_key <YOUR_KEY>"
39+
)
40+
41+
return "ok", "Tavily 全网搜索可用(API Key 已配置)"

agent_reach/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Config:
2121
# Feature → required config keys
2222
FEATURE_REQUIREMENTS = {
2323
"exa_search": ["exa_api_key"],
24+
"tavily_search": ["tavily_api_key"],
2425
"twitter_xreach": ["twitter_auth_token", "twitter_ct0"], # legacy key name; used by bird CLI
2526
"groq_whisper": ["groq_api_key"],
2627
"github_token": ["github_token"],

agent_reach/guides/setup-tavily.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Tavily Search Setup
2+
3+
Tavily is an API-based web search provider designed for AI agents. It offers 1,000 free API credits per month.
4+
5+
## 1. Get an API Key
6+
7+
1. Visit [https://app.tavily.com](https://app.tavily.com)
8+
2. Sign up for a free account (no credit card required)
9+
3. Copy your API key (starts with `tvly-`)
10+
11+
## 2. Configure Agent Reach
12+
13+
```bash
14+
agent-reach configure tavily_api_key tvly-YOUR_API_KEY
15+
```
16+
17+
Or set the environment variable directly:
18+
19+
```bash
20+
export TAVILY_API_KEY="tvly-YOUR_API_KEY"
21+
```
22+
23+
## 3. Verify
24+
25+
```bash
26+
agent-reach doctor
27+
```
28+
29+
You should see `tavily_search` show as **ok**.
30+
31+
## Notes
32+
33+
- Tavily is a Tier-2 channel (requires API key)
34+
- Exa Search remains available as the free/zero-config alternative
35+
- Install the Python SDK if not already present: `pip install tavily-python`

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ dependencies = [
4040
[project.optional-dependencies]
4141
browser = ["playwright>=1.40"]
4242
cookies = ["browser-cookie3>=0.19"]
43-
all = ["playwright>=1.40", "mcp[cli]>=1.0", "browser-cookie3>=0.19"]
43+
search = ["tavily-python>=0.3"]
44+
all = ["playwright>=1.40", "mcp[cli]>=1.0", "browser-cookie3>=0.19", "tavily-python>=0.3"]
4445
dev = [
4546
"pytest>=8.0",
4647
"ruff>=0.8",

0 commit comments

Comments
 (0)