Skip to content

Commit 1d1a3a2

Browse files
author
maekblack
committed
feat: Tavily AI 搜索
1 parent 1246b1c commit 1d1a3a2

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed
6.43 KB
Binary file not shown.

tools/tool_tavily_search/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# ArXiv 学术搜索工具
2+
3+
搜索 ArXiv 学术论文,获取论文元数据。
4+
5+
## 功能特点
6+
7+
- 学术论文搜索
8+
- 按分类筛选
9+
- 按日期/相关性排序
10+
- 返回摘要/作者/链接
11+
12+
## 参数说明
13+
14+
**输入参数**: query, category, max_results, sort_by
15+
```python
16+
def search_with_tavily(
17+
query: str,
18+
api_key: str,
19+
search_depth: str = "basic",
20+
topic: str = "general",
21+
max_results: int = 5,
22+
include_answer: bool = False,
23+
include_raw_content: bool = False,
24+
include_domains: Optional[List[str]] = None,
25+
exclude_domains: Optional[List[str]] = None
26+
) -> Dict[str, Any]:
27+
"""使用 Tavily AI 搜索引擎进行搜索
28+
29+
Args:
30+
query: 搜索查询词
31+
api_key: Tavily API 密钥
32+
search_depth: 搜索深度,可选 "basic" 或 "advanced",默认 "basic"
33+
topic: 搜索主题,可选 "general"/"news"/"science",默认 "general"
34+
max_results: 最大返回结果数,默认 5
35+
include_answer: 是否包含 AI 生成的答案,默认 False
36+
include_raw_content: 是否包含原始网页内容,默认 False
37+
include_domains: 限定搜索的域名列表(可选)
38+
exclude_domains: 排除的域名列表(可选)
39+
40+
Returns:
41+
Dict[str, Any]: 包含搜索结果的字典,结构如下:
42+
- success (bool): 是否成功
43+
- data (Dict|None): 搜索数据,包含:
44+
- query (str): 搜索查询
45+
- answer (str|None): AI 生成的答案
46+
- results (List): 搜索结果列表,每项包含:
47+
- title (str): 标题
48+
- url (str): URL
49+
- content (str): 内容摘要
50+
- score (float): 相关性分数
51+
- raw_content (str|None): 原始内容
52+
- message (str): 结果消息
53+
54+
Raises:
55+
无异常抛出,所有错误在返回值中处理
56+
57+
Examples:
58+
>>> result = search_with_tavily("Python 教程", api_key="tvly-xxx", max_results=3)
59+
>>> if result["success"]:
60+
... for r in result["data"]["results"]:
61+
... print(f"{r['title']}: {r['url']}")
62+
"""
63+
```
64+
**启动参数**: 无
65+
66+
## 使用示例
67+
68+
```
69+
query: machine learning
70+
category: cs.AI
71+
max_results: 10
72+
sort_by: submittedDate
73+
```

tools/tool_tavily_search/data.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: ArXiv 学术搜索
2+
tags:
3+
- 联网搜索
4+
title: ArXiv 论文搜索
5+
description: 搜索 ArXiv 学术论文,支持按分类/日期/相关性排序,返回论文标题/摘要/作者/链接等信息

tools/tool_tavily_search/logo.png

883 Bytes
Loading

0 commit comments

Comments
 (0)