v0.12: stabilize search routing and profile-driven phase4 pipeline

This commit is contained in:
kai
2026-04-29 15:53:20 +08:00
parent 450ecebcff
commit 5342a26018
33 changed files with 1436 additions and 140 deletions
+58 -18
View File
@@ -82,7 +82,46 @@ description: 生物医药深度研究的统一检索策略。规定信源优先
---
## 三、API 调用顺序(技术栈,v0.8 更新
## 三、强制工具入口(v0.12
所有 agent 做联网检索时,**优先调用项目内 Python 网关**,不要直接把 Tavily / Brave / Exa MCP 当成主路径:
```bash
uv run python scripts/search.py "<query>" --route scholar --num-results 10 --year-low 2023
uv run python scripts/search.py "<query>" --route patents --num-results 10
uv run python scripts/search.py "<query>" --route news --num-results 10 --time-range m
uv run python scripts/search.py "<query>" --route general --num-results 10
uv run python scripts/search.py "<query>" --profile china_market --num-results 10 --trace
uv run python scripts/ground.py "<query>" --model google/gemini-3.1-flash-lite-preview --json
```
也可以按研究场景跑 profile
```bash
uv run python scripts/search.py "<query>" --profile biomed_literature --num-results 10 --year-low 2023
uv run python scripts/search.py "<query>" --profile patent_heavy --num-results 10
```
**原因**
- Python 网关在 repo 内,可被 OpenCode / Codex / Gemini CLI / Claude Code 共同复用。
- `--route patents` 固定优先 Serper + Google Patents,避免专利检索被 Tavily 普通网页结果替代。
- `--route scholar` 固定优先 Serper Scholar,避免论文检索只停留在通用网页摘要。
- 专用 routescholar/patents/news)默认 `--strict-specialized`,Serper 异常时应显式失败,不允许静默降级。
- Tavily / Exa / Brave 只作为 gap-fill 或 MCP 兜底,不作为文献/专利主路径。
每个检索小结必须写明实际使用过的 route,例如:
```text
Routes used: scholar, patents, general
```
如果由于缺 key 或 API 错误无法调用 Serper,必须在输出中明确写(且建议重新执行,不直接进入正文证据):
```text
Serper unavailable: <原因>; fallback used: general site:patents.google.com
```
## 四、API 调用顺序(技术栈,v0.11 更新)
**按"查询类型"路由到最合适的 API**,而不是一律走通用搜索。
@@ -114,24 +153,23 @@ description: 生物医药深度研究的统一检索策略。规定信源优先
### Serpergoogle.serper.dev)使用模板
**专利检索**
```python
from scripts.lib.search_client import SearchClient
with SearchClient() as c:
hits = c.patents("dual-target siRNA GalNAc", num_results=10)
```bash
uv run python scripts/search.py "dual-target siRNA GalNAc" --route patents --num-results 10
```
**学术论文**
```python
hits = c.scholar("dual-target RNAi 2024", num_results=10, year_low=2023)
# hits[i].snippet 里包含引用数和期刊信息
```bash
uv run python scripts/search.py "dual-target RNAi 2024" --route scholar --num-results 10 --year-low 2023
```
**新闻(时效性)**
```python
hits = c.news("Arrowhead ARO-DIMER-PA clinical trial", time_range="w") # 最近一周
```bash
uv run python scripts/search.py "Arrowhead ARO-DIMER-PA clinical trial" --route news --num-results 10 --time-range w
```
### Tavily MCP 调用模板(通用网页 - Phase 1 初扫
### Tavily MCP 调用模板(兜底,不作为主路径
仅当 `scripts/search.py` 不可用,或需要 MCP 特有能力时使用。通用网页结果必须回溯到 Tier 1-2 原始来源。
```
工具名:tavily_search
参数:
@@ -171,7 +209,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
---
## 、关键词策略
## 、关键词策略
### 中英双语必备
- 任何生物医药主题**必须同时用中英文检索**
@@ -195,7 +233,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
---
## 、每条信源的提取字段(标准化)
## 、每条信源的提取字段(标准化)
任何信源进 `sources.jsonl` 必须有以下字段:
@@ -225,7 +263,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
---
## 、失败兜底
## 、失败兜底
- 某个 API 限流/超时:**等 5s 重试 3 次**,仍失败则跳过并在日志标注
- 某个信源 404:在 sources.jsonl 标 `"dead_link": true`,不删除(审计用)
@@ -233,7 +271,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
---
## 、硬规则总结
## 、硬规则总结
1. ✅ 每 section 至少 4 轮检索
2. ✅ 中英双语必查
@@ -241,6 +279,8 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
4. ✅ 反方关键词必查
5. ✅ Tier 4 结果只做发现,不做佐证
6. ✅ 所有信源写入 sources.jsonl 并评分
7. ❌ 不得引用 Wikipedia 做结论
8. ❌ 不得编造数据、URL、DOI
9. ❌ 不得使用黑名单信源
7. ✅ 文献检索必须优先 `scripts/search.py --route scholar`
8. ✅ 专利检索必须优先 `scripts/search.py --route patents`
9. ❌ 不得引用 Wikipedia 做结论
10. ❌ 不得编造数据、URL、DOI
11. ❌ 不得使用黑名单信源