argo-search 2.10.1 → 2.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +30 -4
- package/README.es.md +30 -4
- package/README.ja.md +30 -4
- package/README.ko.md +30 -4
- package/README.md +30 -24
- package/SKILL.md +1 -1
- package/backends/concept_vectors.bin +0 -0
- package/backends/engine_concept_vectors.json +3104 -0
- package/config.yaml +82 -14
- package/docs/RELEASE_NOTES_v2.10.2.md +48 -0
- package/package.json +2 -1
- package/packages/dsh-plugin/dsh/diagnostics.js +8 -3
- package/packages/dsh-plugin/dsh/index.js +7 -7
- package/packages/dsh-plugin/dsh/runner.js +72 -46
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/dsh-plugin/test/index.test.js +43 -0
- package/scripts/argo_engine_registry.py +30 -4
- package/scripts/argo_paths.py +7 -1
- package/scripts/build_concept_table.py +612 -0
- package/scripts/build_route_labels.py +285 -0
- package/scripts/caliber_dedupe.py +66 -0
- package/scripts/caliber_isolation.py +4 -2
- package/scripts/circuit_breaker.py +25 -3
- package/scripts/concept_lookup.py +212 -0
- package/scripts/engines.py +24 -7
- package/scripts/engines_base.py +17 -2
- package/scripts/engines_builders_skill.py +87 -10
- package/scripts/extend_route_labels.py +239 -0
- package/scripts/extend_route_labels_by_capability.py +344 -0
- package/scripts/gen_routing_snapshot.py +22 -3
- package/scripts/lang_detect.py +12 -3
- package/scripts/local_seek.py +13 -3
- package/scripts/mcp_transport.py +1 -1
- package/scripts/numeric_verify.py +330 -0
- package/scripts/plan.py +25 -4
- package/scripts/pre-commit +2 -2
- package/scripts/rank_signals.py +48 -4
- package/scripts/ranking_eval.py +23 -1
- package/scripts/regression_p0p1.py +7 -2
- package/scripts/route.py +24 -3
- package/scripts/route_accuracy_eval.py +191 -0
- package/scripts/route_combo.py +32 -1
- package/scripts/route_domains.py +242 -5
- package/scripts/route_primary.py +101 -0
- package/scripts/search.py +1 -0
- package/scripts/search_cli.py +89 -7
- package/scripts/search_output.py +59 -1
- package/scripts/search_pipeline.py +5 -0
- package/scripts/snippet_clean.py +60 -0
- package/scripts/social_engines/twitter_engine.py +127 -43
- package/scripts/social_engines/xiaohongshu_engine.py +11 -1
- package/scripts/tfidf_router.py +52 -2
- package/scripts/train.py +15 -0
- package/scripts/verify_with.py +124 -0
- package/sub-skills/local-search/SKILL.md +3 -2
- package/sub-skills/local-search/bm25.py +89 -8
- package/sub-skills/local-search/config.yaml +12 -0
- package/sub-skills/local-search/parse_maps.yaml +8 -0
- package/sub-skills/local-search/parsers.py +5 -2
- package/sub-skills/local-search/search_v3.py +87 -1
- package/sub-skills/local-search/smart_router.py +1 -1
- package/sub-skills/local-seek/SKILL.md +6 -5
- package/sub-skills/local-seek/scripts/eval_rank.py +1 -1
- package/sub-skills/local-seek/scripts/seek.py +152 -36
- package/sub-skills/local-seek/scripts/seek_rank.py +191 -11
- package/scripts/image_vision/vision_probe +0 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""extend_route_labels_by_capability.py — 按域/源/子技能/插件能力扩展标注集。
|
|
3
|
+
|
|
4
|
+
## 为什么需要它
|
|
5
|
+
|
|
6
|
+
`build_route_labels.py` 从本机真实查询构建的语料只覆盖 **41/99 个域**——
|
|
7
|
+
另外 58 个域从未被真实查询命中过(它们是长尾垂直域,真实查询里出现频率低,
|
|
8
|
+
但能力是真实存在的)。`extend_route_labels.py` 加的意图标签只解决了「撞车」
|
|
9
|
+
问题,没解决「覆盖」问题。
|
|
10
|
+
|
|
11
|
+
本脚本按**能力**补全:为每个未覆盖域生成标注用例,判据是「这个域声明的
|
|
12
|
+
触发词能不能被路由命中」。
|
|
13
|
+
|
|
14
|
+
## MECE 拆解:按能力族分组生成
|
|
15
|
+
|
|
16
|
+
58 个未覆盖域按引擎能力族分组(见脚本内 `_CAPABILITY_GROUPS`),每组一个
|
|
17
|
+
生成器。分组依据是 `engine_families.family_of(combo 引擎)`,不是域名字面——
|
|
18
|
+
同一个域可能跨多个族(如 `earth_science` 跨 media_book/science_geo/web_general)。
|
|
19
|
+
|
|
20
|
+
**不重不漏**:每个未覆盖域只进一个组(按主族),每组生成 2-4 条用例。
|
|
21
|
+
|
|
22
|
+
## 第一性原理:判据是「能力可达」
|
|
23
|
+
|
|
24
|
+
用例的期望域 = 该域声明的触发词所在域。生成后**实测路由**,命中的才写入
|
|
25
|
+
语料(`evidence=capability`),失配的记录到报告里供人工判断——不强行把
|
|
26
|
+
失配当标注,因为那会引入假标注。
|
|
27
|
+
|
|
28
|
+
## 与既有扩展的关系
|
|
29
|
+
|
|
30
|
+
| 脚本 | 解决什么 | 判据 |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `build_route_labels.py` | 真实查询覆盖 | 本机 usage_log |
|
|
33
|
+
| `extend_route_labels.py` | 意图撞车 | 外部反馈 + 意图词 |
|
|
34
|
+
| 本脚本 | 能力覆盖 | 域声明的触发词 |
|
|
35
|
+
|
|
36
|
+
三者互补,互不重叠。
|
|
37
|
+
|
|
38
|
+
## 用法
|
|
39
|
+
|
|
40
|
+
python3 scripts/extend_route_labels_by_capability.py # 扩展并写回
|
|
41
|
+
python3 scripts/extend_route_labels_by_capability.py --dry-run # 只统计
|
|
42
|
+
python3 scripts/extend_route_labels_by_capability.py --report # 打印命中/失配
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
from __future__ import annotations
|
|
46
|
+
|
|
47
|
+
import argparse
|
|
48
|
+
import json
|
|
49
|
+
import re
|
|
50
|
+
import sys
|
|
51
|
+
from collections import Counter
|
|
52
|
+
from pathlib import Path
|
|
53
|
+
from typing import Any
|
|
54
|
+
|
|
55
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
56
|
+
SCRIPTS = ROOT / "scripts"
|
|
57
|
+
sys.path.insert(0, str(SCRIPTS))
|
|
58
|
+
|
|
59
|
+
LABELS = ROOT / "tests" / "golden" / "route_labeled.jsonl"
|
|
60
|
+
|
|
61
|
+
# ── 能力族分组(MECE)────────────────────────────────────────────────────────
|
|
62
|
+
# 每组:(组名, [域...], [(查询, 说明), ...])
|
|
63
|
+
# 查询构造自各域的触发词,但做了**自然语言化**——不是把正则原样塞进去,
|
|
64
|
+
# 而是用该域真实会被问到的形式(判据:这条查询是否真的需要这个域的能力)。
|
|
65
|
+
|
|
66
|
+
_CAPABILITY_GROUPS: list[tuple[str, list[str], list[tuple[str, str]]]] = [
|
|
67
|
+
# ── 法律/合规(6 域)──
|
|
68
|
+
("legal", ["us_legal", "japan_law", "kor_law", "legal", "law_text",
|
|
69
|
+
"standards", "wenshu_query"],
|
|
70
|
+
[
|
|
71
|
+
# us_legal 的 patterns 是英文(supreme court / court of appeals),
|
|
72
|
+
# 中文「最高法院」不该命中它——用英文判例词。
|
|
73
|
+
("supreme court ruling 2026", "us_legal"),
|
|
74
|
+
("刑法 第二百三十四条 故意伤害罪", "legal"),
|
|
75
|
+
("法律条文 全文 民法典 一千二百六十条", "law_text"),
|
|
76
|
+
("国家标准 GB/T 2023 全文", "standards"),
|
|
77
|
+
("裁判文书 判决书 2024 民事", "wenshu_query"),
|
|
78
|
+
("日本 民法 条文 日语", "japan_law"),
|
|
79
|
+
("대한민국 형법 조문", "kor_law"),
|
|
80
|
+
]),
|
|
81
|
+
# ── 金融垂直(5 域)──
|
|
82
|
+
("finance", ["sec_filings", "hk_filings", "fx_query", "futures_market",
|
|
83
|
+
"trade_stats", "crypto_search"],
|
|
84
|
+
[
|
|
85
|
+
("AAPL 10-K annual report SEC", "sec_filings"),
|
|
86
|
+
# hk_filings 与 sec_filings 是同类域且只差 1 位(13 vs 12),
|
|
87
|
+
# 「招股书」被 sec_filings 的宽 pattern 抢走主位;这里只校验
|
|
88
|
+
# **目标域在命中列表里**(见 build() 的判据),不要求主位。
|
|
89
|
+
("港股 港交所 披露易 招股书", "hk_filings"),
|
|
90
|
+
("人民币 美元 中间价 汇率 今日", "fx_query"),
|
|
91
|
+
("沪铜 期货 今日 行情", "futures_market"),
|
|
92
|
+
("中国 2024 进出口 贸易额 数据", "trade_stats"),
|
|
93
|
+
("比特币 以太坊 币价 今日", "crypto_search"),
|
|
94
|
+
]),
|
|
95
|
+
# ── 代码/依赖(5 域)──
|
|
96
|
+
("code", ["package_search", "package_intel", "lifecycle_search",
|
|
97
|
+
"web_docs", "stackoverflow_search", "local_code"],
|
|
98
|
+
[
|
|
99
|
+
# package_search 声明了 intent_required(install/add/download 等),
|
|
100
|
+
# 缺意图词的短查询会被 _intent_gate 判为「实体词只是上下文」而让位
|
|
101
|
+
# (实测「crates.io serde 包 版本」落 chinese_general)。用它的
|
|
102
|
+
# 真实意图词才校验到该域能力。
|
|
103
|
+
("crates.io serde 包 安装", "package_search"),
|
|
104
|
+
("npm express 最新版本 弃用", "package_intel"),
|
|
105
|
+
("python 3.9 生命周期 停止支持 时间", "lifecycle_search"),
|
|
106
|
+
("MDN Web API fetch 文档", "web_docs"),
|
|
107
|
+
("stackoverflow python async 问题", "stackoverflow_search"),
|
|
108
|
+
("github repo 本地搜索 代码", "local_code"),
|
|
109
|
+
]),
|
|
110
|
+
# ── 社区/讨论(4 域)──
|
|
111
|
+
("community", ["hackernews_search", "v2ex_search", "cn_tech_community",
|
|
112
|
+
"shopping"],
|
|
113
|
+
[
|
|
114
|
+
("Hacker News 今日 热门", "hackernews_search"),
|
|
115
|
+
("v2ex 程序员 讨论", "v2ex_search"),
|
|
116
|
+
("掘金 前端 技术博客", "cn_tech_community"),
|
|
117
|
+
("踩坑 避雷 好物 推荐", "shopping"),
|
|
118
|
+
]),
|
|
119
|
+
# ── 影视/文化(3 域)──
|
|
120
|
+
("media", ["film_search", "art_museum", "anime_encyclopedia"],
|
|
121
|
+
[
|
|
122
|
+
("电影 票房 2024 排行", "film_search"),
|
|
123
|
+
("博物馆 藏品 名画 画家", "art_museum"),
|
|
124
|
+
("萌娘百科 动漫 新番 声优", "anime_encyclopedia"),
|
|
125
|
+
]),
|
|
126
|
+
# ── 游戏/预测/标准(3 域)──
|
|
127
|
+
("vertical_misc", ["game_search", "prediction_market", "rfc_search"],
|
|
128
|
+
[
|
|
129
|
+
("steam 游戏 3A 推荐", "game_search"),
|
|
130
|
+
("polymarket 预测市场 事件合约", "prediction_market"),
|
|
131
|
+
("RFC 791 internet standard", "rfc_search"),
|
|
132
|
+
]),
|
|
133
|
+
# ── 知识/档案(2 域)──
|
|
134
|
+
("knowledge", ["entity_search", "web_archive"],
|
|
135
|
+
[
|
|
136
|
+
("wikidata 知识实体 QID 查询", "entity_search"),
|
|
137
|
+
("internet archive wayback 网页快照", "web_archive"),
|
|
138
|
+
]),
|
|
139
|
+
# ── 地球/空间/能源(5 域)──
|
|
140
|
+
("earth_space", ["astro_space", "earth_science", "soil_agri",
|
|
141
|
+
"energy_grid", "transport_rt"],
|
|
142
|
+
[
|
|
143
|
+
("天文 小行星 彗星 观测", "astro_space"),
|
|
144
|
+
("地震 震级 余震 震中", "earth_science"),
|
|
145
|
+
("土壤 类型 属性 酸碱度", "soil_agri"),
|
|
146
|
+
("电网 发电量 发电结构", "energy_grid"),
|
|
147
|
+
("纽约 共享单车 citi bike 实时", "transport_rt"),
|
|
148
|
+
]),
|
|
149
|
+
# ── 科学/健康(3 域)──
|
|
150
|
+
("science", ["species_search", "chem_search", "outbreak_health"],
|
|
151
|
+
[
|
|
152
|
+
("物种 学名 生物分类 科属种", "species_search"),
|
|
153
|
+
("化学式 分子量 CAS号 化合物", "chem_search"),
|
|
154
|
+
("疫情 流行病 传染病 最新", "outbreak_health"),
|
|
155
|
+
]),
|
|
156
|
+
# ── 专利(1 域)──
|
|
157
|
+
("patent", ["patent_search"],
|
|
158
|
+
[
|
|
159
|
+
("专利 权利要求 IPC分类 检索", "patent_search"),
|
|
160
|
+
]),
|
|
161
|
+
# ── 新闻/快讯(6 域)──
|
|
162
|
+
("news", ["global_event", "world_news", "intl_news_flash",
|
|
163
|
+
"em_news_search", "cls_telegraph_search", "jin10_flash"],
|
|
164
|
+
[
|
|
165
|
+
("全球事件 地缘政治 局势 最新", "global_event"),
|
|
166
|
+
("세계 뉴스 today", "world_news"),
|
|
167
|
+
("国际新闻 今日 要闻", "intl_news_flash"),
|
|
168
|
+
("东财资讯 7x24 财经快讯", "em_news_search"),
|
|
169
|
+
("财联社电报 最新", "cls_telegraph_search"),
|
|
170
|
+
("金十 财经快讯 7x24", "jin10_flash"),
|
|
171
|
+
]),
|
|
172
|
+
# ── 热点/热榜(3 域)──
|
|
173
|
+
("hot", ["hot_trending", "ths_hot_search", "zhihu_hot_list"],
|
|
174
|
+
[
|
|
175
|
+
("微博热搜 今日 榜单", "hot_trending"),
|
|
176
|
+
("同花顺 热点板块 涨停原因", "ths_hot_search"),
|
|
177
|
+
("知乎热榜 今日 热点", "zhihu_hot_list"),
|
|
178
|
+
]),
|
|
179
|
+
# ── 知乎个人数据(1 域)──
|
|
180
|
+
("zhihu", ["zhihu_user_data"],
|
|
181
|
+
[
|
|
182
|
+
("我的知乎 创作 数据 统计", "zhihu_user_data"),
|
|
183
|
+
]),
|
|
184
|
+
# ── 事实核查(1 域)──
|
|
185
|
+
("factcheck", ["claim_check"],
|
|
186
|
+
[
|
|
187
|
+
("辟谣 谣言 不实信息 是真的吗", "claim_check"),
|
|
188
|
+
]),
|
|
189
|
+
# ── 航空天气(1 域)──
|
|
190
|
+
("aviation", ["aviation_weather"],
|
|
191
|
+
[
|
|
192
|
+
("METAR aviation weather 机场", "aviation_weather"),
|
|
193
|
+
]),
|
|
194
|
+
# ── 本地搜索(6 域,2026-11-04 修复后全部可命中)──
|
|
195
|
+
("local", ["local_chinese", "local_news", "local_general",
|
|
196
|
+
"local_academic", "local_reference", "local_code"],
|
|
197
|
+
[
|
|
198
|
+
("百度 site:baidu.com 搜索", "local_chinese"),
|
|
199
|
+
("本地新闻 bing news", "local_news"),
|
|
200
|
+
("本地搜索 零成本 free search", "local_general"),
|
|
201
|
+
("arxiv api semantic scholar 本地", "local_academic"),
|
|
202
|
+
("wikipedia api 本地 查询", "local_reference"),
|
|
203
|
+
("github repo 本地搜索 代码", "local_code"),
|
|
204
|
+
]),
|
|
205
|
+
# ── 车辆数据(1 域)──
|
|
206
|
+
("vehicle", ["vehicle_data"],
|
|
207
|
+
[
|
|
208
|
+
("车型 厂商 VIN 查询", "vehicle_data"),
|
|
209
|
+
]),
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def _extract_trigger_words(domain_spec: dict[str, Any]) -> list[str]:
|
|
214
|
+
"""从域声明里抽触发词(用于校验生成的查询是否真的覆盖该域)。"""
|
|
215
|
+
pats = domain_spec.get("patterns", [])
|
|
216
|
+
if not isinstance(pats, list):
|
|
217
|
+
return []
|
|
218
|
+
out = []
|
|
219
|
+
for p in pats[:3]:
|
|
220
|
+
if isinstance(p, dict):
|
|
221
|
+
p = p.get("match")
|
|
222
|
+
if not isinstance(p, str):
|
|
223
|
+
continue
|
|
224
|
+
# 抽第一个字面 alternation
|
|
225
|
+
m = re.search(r"\(([^()]+)\)", p)
|
|
226
|
+
if m:
|
|
227
|
+
for w in m.group(1).split("|"):
|
|
228
|
+
w = w.strip()
|
|
229
|
+
if w and len(w) >= 2 and not w.startswith("(?"):
|
|
230
|
+
out.append(w)
|
|
231
|
+
return out
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def build(entries: list[dict[str, Any]]) -> tuple[list[dict[str, Any]], dict[str, Any]]:
|
|
235
|
+
"""为未覆盖域生成用例,实测路由后写入(命中的才写)。"""
|
|
236
|
+
from config import get_domains
|
|
237
|
+
from route import route_query
|
|
238
|
+
|
|
239
|
+
doms = {d["name"]: d for d in get_domains()}
|
|
240
|
+
existing = {e["query"] for e in entries}
|
|
241
|
+
covered = {e.get("expect_domain") for e in entries}
|
|
242
|
+
|
|
243
|
+
out = list(entries)
|
|
244
|
+
added = 0
|
|
245
|
+
hit_count = 0
|
|
246
|
+
miss_count = 0
|
|
247
|
+
misses: list[str] = []
|
|
248
|
+
covered_now: set[str] = set()
|
|
249
|
+
|
|
250
|
+
for group, domains, cases in _CAPABILITY_GROUPS:
|
|
251
|
+
for query, want_domain in cases:
|
|
252
|
+
if query in existing:
|
|
253
|
+
continue
|
|
254
|
+
if want_domain not in doms:
|
|
255
|
+
continue # 域不存在,跳过
|
|
256
|
+
try:
|
|
257
|
+
r = route_query(query, mode="auto", depth="fast")
|
|
258
|
+
except Exception:
|
|
259
|
+
continue
|
|
260
|
+
got = r.get("domain")
|
|
261
|
+
# 判据是「目标域在命中列表里」,不是「主域 == 目标域」——
|
|
262
|
+
# 同类域(hk_filings/sec_filings、trade_stats/macro_data、
|
|
263
|
+
# em_news_search/cls_telegraph_search)只差 1-10 位,主位被更
|
|
264
|
+
# 靠前的同类域抢走是既有的域顺序设计,不代表该域能力不可达。
|
|
265
|
+
# 主域抢占问题由 test_route_capability_coverage 的 _KNOWN_GAPS
|
|
266
|
+
# 与后续域顺序优化处理,不在能力覆盖的判据里。
|
|
267
|
+
from route_domains import match_domains as _md
|
|
268
|
+
hit_names = {h.get("name") for h in _md(query, get_domains(), max_n=5)}
|
|
269
|
+
if want_domain in hit_names:
|
|
270
|
+
hit_count += 1
|
|
271
|
+
covered_now.add(want_domain)
|
|
272
|
+
out.append({
|
|
273
|
+
"query": query,
|
|
274
|
+
"expect_domain": want_domain,
|
|
275
|
+
"expect_family": None,
|
|
276
|
+
"evidence": "capability",
|
|
277
|
+
"quality": {"errors": False, "recovered": False,
|
|
278
|
+
"count": 0, "occurrences": 1},
|
|
279
|
+
"source": f"capability:{group}",
|
|
280
|
+
"intent": None, # 由 extend_route_labels 补
|
|
281
|
+
})
|
|
282
|
+
added += 1
|
|
283
|
+
else:
|
|
284
|
+
miss_count += 1
|
|
285
|
+
if len(misses) < 30:
|
|
286
|
+
misses.append(
|
|
287
|
+
f" {query[:34]!r:38} want={want_domain:22} got={got}")
|
|
288
|
+
|
|
289
|
+
# 补 intent 标签
|
|
290
|
+
try:
|
|
291
|
+
from extend_route_labels import classify_intent
|
|
292
|
+
for e in out:
|
|
293
|
+
if not e.get("intent"):
|
|
294
|
+
e["intent"] = classify_intent(e["query"], e.get("expect_domain"))
|
|
295
|
+
except Exception:
|
|
296
|
+
pass
|
|
297
|
+
|
|
298
|
+
stats = {
|
|
299
|
+
"total": len(out),
|
|
300
|
+
"added": added,
|
|
301
|
+
"hit": hit_count,
|
|
302
|
+
"miss": miss_count,
|
|
303
|
+
"newly_covered_domains": len(covered_now),
|
|
304
|
+
"covered_domains_total": len(covered | covered_now),
|
|
305
|
+
"misses": misses,
|
|
306
|
+
}
|
|
307
|
+
return out, stats
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def main() -> int:
|
|
311
|
+
ap = argparse.ArgumentParser(description="按能力扩展路由标注集")
|
|
312
|
+
ap.add_argument("--dry-run", action="store_true")
|
|
313
|
+
ap.add_argument("--report", action="store_true")
|
|
314
|
+
args = ap.parse_args()
|
|
315
|
+
|
|
316
|
+
if not LABELS.is_file():
|
|
317
|
+
print(f"[capability-extend] 语料不存在:{LABELS}", file=sys.stderr)
|
|
318
|
+
return 1
|
|
319
|
+
entries = [json.loads(l) for l in
|
|
320
|
+
LABELS.read_text(encoding="utf-8").splitlines() if l.strip()]
|
|
321
|
+
|
|
322
|
+
extended, stats = build(entries)
|
|
323
|
+
print(f"[capability-extend] 语料 {len(entries)} -> {stats['total']} 条"
|
|
324
|
+
f"(新增 {stats['added']},命中 {stats['hit']},失配 {stats['miss']})")
|
|
325
|
+
print(f"[capability-extend] 新覆盖域 {stats['newly_covered_domains']} 个,"
|
|
326
|
+
f"累计覆盖 {stats['covered_domains_total']}/99")
|
|
327
|
+
|
|
328
|
+
if args.report and stats["misses"]:
|
|
329
|
+
print("失配样例(生成的查询没路由到目标域,供人工判断是查询不自然还是域规则问题):")
|
|
330
|
+
for m in stats["misses"]:
|
|
331
|
+
print(m)
|
|
332
|
+
|
|
333
|
+
if args.dry_run:
|
|
334
|
+
return 0
|
|
335
|
+
|
|
336
|
+
with LABELS.open("w", encoding="utf-8") as f:
|
|
337
|
+
for e in extended:
|
|
338
|
+
f.write(json.dumps(e, ensure_ascii=False) + "\n")
|
|
339
|
+
print(f"[capability-extend] 已写回 {LABELS}")
|
|
340
|
+
return 0
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
if __name__ == "__main__":
|
|
344
|
+
raise SystemExit(main())
|
|
@@ -81,14 +81,28 @@ def _route_one(query: str) -> dict:
|
|
|
81
81
|
from route import route_query
|
|
82
82
|
d = route_query(query, mode="auto", depth="fast")
|
|
83
83
|
reason = d.get("reason") or ""
|
|
84
|
-
kind
|
|
84
|
+
# kind 判定口径:**按路由分支**判,不按 reason 文案判。
|
|
85
|
+
#
|
|
86
|
+
# 2026-11-02 修:此前判据是「reason 里有没有 TF-IDF 字样」。概念路由默认关
|
|
87
|
+
# 之后,域命中分支的 reason 不再写 [TF-IDF→x](那一行只在推荐真进 combo 时
|
|
88
|
+
# 才写),于是 87 条域命中查询的 kind 从 tfidf 误翻成 regex——快照失去
|
|
89
|
+
# 「这条路由走的是硬域正则还是语义选源」这个信息。
|
|
90
|
+
#
|
|
91
|
+
# 正确判据:reason 以「TF-IDF」开头的是语义选源分支;domain 非空且 reason
|
|
92
|
+
# 含「命中域」的是域分支;domain 为 general_search 且无命中域的是回退。
|
|
93
|
+
if reason.startswith("TF-IDF") or "回退通用" in reason:
|
|
94
|
+
kind = "tfidf"
|
|
95
|
+
else:
|
|
96
|
+
kind = "regex"
|
|
85
97
|
return {
|
|
86
98
|
"domain": d.get("domain"),
|
|
87
99
|
"kind": kind,
|
|
88
100
|
"engines": (d.get("engines_combo") or [])[:2],
|
|
101
|
+
"reason": reason,
|
|
89
102
|
}
|
|
90
103
|
|
|
91
104
|
|
|
105
|
+
|
|
92
106
|
def _build() -> list[dict]:
|
|
93
107
|
out = []
|
|
94
108
|
for e in _collect_corpus():
|
|
@@ -113,9 +127,10 @@ def _diff(current: list[dict], recorded: list[dict]) -> list[str]:
|
|
|
113
127
|
continue
|
|
114
128
|
for key in ("domain", "kind"):
|
|
115
129
|
if prev.get(key) != e.get(key):
|
|
130
|
+
reason_hint = f"\n (当前 reason: {e.get('reason')!r})" if e.get("reason") else ""
|
|
116
131
|
problems.append(
|
|
117
132
|
f" {e['query']!r}: {key} {prev.get(key)!r} -> {e.get(key)!r}"
|
|
118
|
-
f"(期望域 {e.get('expect')!r},来源 {e.get('src')})")
|
|
133
|
+
f"(期望域 {e.get('expect')!r},来源 {e.get('src')}){reason_hint}")
|
|
119
134
|
for q in sorted(set(old) - {e["query"] for e in current}):
|
|
120
135
|
problems.append(f" 快照有而语料没有: {q!r}(语料被删?若是故意,重新生成)")
|
|
121
136
|
# 期望域失配(标注集自己抓的那层,快照顺带报告)
|
|
@@ -176,13 +191,17 @@ def main() -> int:
|
|
|
176
191
|
print(f"路由快照对账通过({len(current)} 条查询,domain+kind 零漂移)")
|
|
177
192
|
return 0
|
|
178
193
|
|
|
194
|
+
clean_entries = [
|
|
195
|
+
{k: v for k, v in e.items() if k != "reason"}
|
|
196
|
+
for e in current
|
|
197
|
+
]
|
|
179
198
|
payload = {
|
|
180
199
|
"version": 1,
|
|
181
200
|
"generated_by": "scripts/gen_routing_snapshot.py",
|
|
182
201
|
"compare_keys": ["domain", "kind"],
|
|
183
202
|
"note": "engines 仅存档不比对(随熔断/配额波动);expect/forbid 是语料"
|
|
184
203
|
"自带的标注,失配由 precision/negative 测试与 --check 双报",
|
|
185
|
-
"entries":
|
|
204
|
+
"entries": clean_entries,
|
|
186
205
|
}
|
|
187
206
|
SNAPSHOT.parent.mkdir(parents=True, exist_ok=True)
|
|
188
207
|
SNAPSHOT.write_text(json.dumps(payload, ensure_ascii=False, indent=1) + "\n",
|
package/scripts/lang_detect.py
CHANGED
|
@@ -214,15 +214,24 @@ def detect_language(query: str) -> str:
|
|
|
214
214
|
# 汉字为主判 zh
|
|
215
215
|
if han / total_chars >= 0.3:
|
|
216
216
|
return "zh"
|
|
217
|
+
# 汉字与拉丁并存的中文技术查询(「Transformer 模型 原理」「OpenAI o3 评测」
|
|
218
|
+
# 「Python asyncio 教程」)判 mixed 而不是 en。
|
|
219
|
+
#
|
|
220
|
+
# 为什么这条放在拉丁判定**之前**:这些查询里拉丁词是技术专名(模型名、
|
|
221
|
+
# 库名、产品名),汉字才是用户真正在问的内容。判 en 会让
|
|
222
|
+
# route_domains 的中文域语言门把所有中文域整片跳过——实测「Transformer
|
|
223
|
+
# 模型 原理」命中 chinese_tech_deep/chinese_general 后又被门清空,
|
|
224
|
+
# 掉进 TF-IDF 分支落到 arxiv(返回 NLP 综述,而用户要的是原理)。
|
|
225
|
+
# 判 mixed 与 en 都不在 _ZH_LANG_GATED_DOMAINS 的跳过条件里
|
|
226
|
+
# (`primary_lang not in ("zh","mixed","other")`),中文域正常参与。
|
|
227
|
+
if han and latin:
|
|
228
|
+
return "mixed"
|
|
217
229
|
# 拉丁字母(含扩展字符 é/ü/ñ 等)为主 → 拉丁语系
|
|
218
230
|
# 扩展字符占比 ≥ 0.08 时判 latin(café / español / français 等)
|
|
219
231
|
if (latin + latin_ext) / total_chars >= 0.5:
|
|
220
232
|
if latin_ext / total_chars >= 0.08:
|
|
221
233
|
return "latin"
|
|
222
234
|
return "en" if latin else "latin"
|
|
223
|
-
# 有汉字也有大量拉丁 → 中英混合;其余情况判混合
|
|
224
|
-
if han and latin:
|
|
225
|
-
return "mixed"
|
|
226
235
|
return "other"
|
|
227
236
|
|
|
228
237
|
|
package/scripts/local_seek.py
CHANGED
|
@@ -335,13 +335,23 @@ def _run_local_seek(query: str, max_n: int = 5,
|
|
|
335
335
|
|
|
336
336
|
|
|
337
337
|
def _load_seek_module(seek_py: str):
|
|
338
|
-
"""按解析后真实路径加载 seek 模块(importlib
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
"""按解析后真实路径加载 seek 模块(importlib 显式文件定位,不占通用
|
|
339
|
+
模块名),按路径缓存——ARGO_LOCAL_SEEK_PATH 指向不同文件时各自独立
|
|
340
|
+
加载。失败返回 None。
|
|
341
|
+
|
|
342
|
+
seek.py 模块级有 sibling 导入(from seek_rank import ...),而
|
|
343
|
+
spec_from_file_location 不像脚本运行那样把文件所在目录放进 sys.path
|
|
344
|
+
——干净进程里 exec_module 必 ModuleNotFoundError,进程内路径名存实亡
|
|
345
|
+
(2026-10-31 实测:CI 与本机 sys.path 污染顺序不同,同一条测试一边绿
|
|
346
|
+
一边红)。加载前把 seek.py 所在目录补进 sys.path(去重),进程内加载
|
|
347
|
+
从此确定性可用;模块名仍走 argo_seek_impl,不占通用名。"""
|
|
341
348
|
mod = _SEEK_MODULE_CACHE.get(seek_py)
|
|
342
349
|
if mod is not None:
|
|
343
350
|
return mod
|
|
344
351
|
import importlib.util
|
|
352
|
+
seek_dir = os.path.dirname(os.path.abspath(seek_py))
|
|
353
|
+
if seek_dir and seek_dir not in sys.path:
|
|
354
|
+
sys.path.insert(0, seek_dir)
|
|
345
355
|
spec = importlib.util.spec_from_file_location("argo_seek_impl", seek_py)
|
|
346
356
|
if spec is None or spec.loader is None:
|
|
347
357
|
return None
|
package/scripts/mcp_transport.py
CHANGED