基于 Semantic Scholar API 的学术文献查询与深度研究工具,包含 CLI 工具、多智能体研究系统和 Web UI。
在项目根目录创建 .env 文件:
# Semantic Scholar API Key(必需)
# 获取地址:https://www.semanticscholar.org/product/api
Semantic_Search_API_KEY=your_semantic_scholar_api_key
# LLM API 配置(深度研究功能需要)
LLM_BASE_URL=https://api.openai.com/v1 # 或其他兼容 OpenAI 的 API
LLM_API_KEY=your_llm_api_key
LLM_MODEL=gpt-4 # 或 gpt-3.5-turbo, qwen-plus 等
# 可选配置
DEBUG=false# Python 依赖(后端 + deep_scholar)
pip install -r requirements.txt
# 如果使用 deep_scholar 深度研究,还需要:
pip install agno openai sqlalchemy
# Node.js 依赖(前端)
cd web-ui
npm installcd web-ui/backend
uvicorn api:app --host 0.0.0.0 --port 8000 --reload成功标志:
✅ Semantic Scholar client initialized
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000
cd web-ui
npm run dev成功标志:
VITE v6.x.x ready in xxx ms
➜ Local: http://localhost:3000/
打开浏览器访问:http://localhost:3000
semantic_scholar_api/
├── .env # 环境变量配置(需创建)
├── requirements.txt # Python 依赖
├── scholar.py # CLI 统一入口
├── semantic_scholar_client.py # Semantic Scholar API 客户端
│
├── deep_scholar/ # 🤖 多智能体深度研究系统
│ ├── config.py # 配置管理
│ ├── main.py # CLI 入口
│ ├── workflow.py # 工作流定义
│ ├── agents/ # 智能体定义
│ │ ├── searcher.py # 搜索智能体
│ │ ├── analyst.py # 分析智能体
│ │ ├── writer.py # 写作智能体
│ │ ├── critic.py # 评估智能体
│ │ └── team.py # 团队协调器
│ └── tools/ # 工具函数
│
└── web-ui/ # 🌐 Web 界面
├── backend/
│ └── api.py # FastAPI 后端 API
├── App.tsx # React 主组件
├── components/ # UI 组件
├── services/
│ └── apiService.ts # API 调用服务
├── package.json # Node.js 依赖
└── vite.config.ts # Vite 配置
| 变量名 | 必需 | 说明 | 示例 |
|---|---|---|---|
Semantic_Search_API_KEY |
✅ | Semantic Scholar API 密钥 | xxxxxxxx |
LLM_BASE_URL |
深度研究需要 | LLM API 地址 | https://api.openai.com/v1 |
LLM_API_KEY |
深度研究需要 | LLM API 密钥 | sk-xxxxxxxx |
LLM_MODEL |
深度研究需要 | 模型名称 | gpt-4 / qwen-plus |
DEBUG |
❌ | 调试模式 | true / false |
如需修改后端地址,编辑 web-ui/.env.local:
VITE_API_URL=http://localhost:8000| 功能 | 说明 |
|---|---|
| 学术搜索 | 搜索论文,支持年份、排序、引用数筛选 |
| 深度研究 | AI 多智能体协作生成研究报告 |
| 论文详情 | 查看摘要、作者、引用等完整信息 |
| 相似论文 | 基于推荐算法查找相关论文 |
| 参考文献 | 查看论文引用的文献列表 |
| 被引文献 | 查看引用该论文的文献列表 |
| 智能体 | 职责 |
|---|---|
| 研究协调器 | 分析任务,决策调用顺序 |
| 搜索智能体 | 检索 Semantic Scholar 论文 |
| 分析智能体 | 分析论文内容和关键发现 |
| 写作智能体 | 撰写结构化研究报告 |
| 评估智能体 | 评估报告质量,提出改进建议 |
# 关键词搜索
python scholar.py keyword "machine learning" -y 2023-2024 -l 20
# 标题搜索
python scholar.py title "Attention is All You Need"
# DOI 查询
python scholar.py doi "10.1038/s41586-021-03819-2" -c -r
# 作者搜索
python scholar.py author search "Yann LeCun"
# 日期搜索
python scholar.py date "LLM" --today# 交互模式
python -m deep_scholar.main
# 直接研究
python -m deep_scholar.main -q "LLM Agent 最新进展"
# 仅检索
python -m deep_scholar.main -s "transformer attention"# 安装缺失的依赖
pip install fastapi uvicorn python-dotenv agno openai sqlalchemy检查:
.env中 LLM 配置是否正确- LLM API 是否可访问
- 后端日志是否有错误
检查:
- 后端是否在 8000 端口运行
- CORS 是否配置正确(后端已默认允许)
- 前端
VITE_API_URL配置是否正确
- Semantic Scholar API 有速率限制(1次/秒)
- 客户端已内置自动重试机制
- 如频繁触发,建议申请更高配额
MIT