feat(Ask): 检索过程可视化 — RAG 命中记录以 chips 展示,生成前先看见

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
link2026
2026-06-10 06:42:59 +08:00
parent a65c63947b
commit 3f9a2af279
3 changed files with 143 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
import Testing
@testable import
struct RetrievalSummaryTests {
@Test func groupsAndCountsPreservingOrder() {
let chips = HealthExportService.RetrievalSummary.groupedChips(
["血压", "血糖", "血压", "血压", "体重"], cap: 8)
#expect(chips == ["血压 ×3", "血糖", "体重"])
}
@Test func capsAndAppendsOverflow() {
let names = (1...12).map { "指标\($0)" }
let chips = HealthExportService.RetrievalSummary.groupedChips(names, cap: 8)
#expect(chips.count == 9)
#expect(chips.last == "+4")
}
@Test func emptyInputGivesEmptyChips() {
#expect(HealthExportService.RetrievalSummary.groupedChips([], cap: 8).isEmpty)
}
}