fix(router): keyword match tiebreaker should preserve list order, not alphabetical
This commit is contained in:
parent
d1250cf32b
commit
4ea7801bcf
|
|
@ -101,8 +101,8 @@ class IntentRouter:
|
||||||
if not candidates:
|
if not candidates:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 按得分降序排序,得分相同时按 skill 名称字母序稳定排序
|
# 按得分降序排序;得分相同时保持列表顺序(Python sort 稳定)
|
||||||
candidates.sort(key=lambda c: (-c[2], c[0].name))
|
candidates.sort(key=lambda c: -c[2])
|
||||||
best_skill, best_kws, _best_score = candidates[0]
|
best_skill, best_kws, _best_score = candidates[0]
|
||||||
confidence = min(1.0, 0.5 + 0.1 * len(best_kws))
|
confidence = min(1.0, 0.5 + 0.1 * len(best_kws))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue