Wire up query history: localStorage session persistence + sidebar UI
This commit is contained in:
@@ -177,6 +177,49 @@ class TestSectionResolver:
|
||||
)
|
||||
|
||||
|
||||
class TestSectionResolverResolveAll:
|
||||
"""`resolve_all` — the fix for `abstain/incomplete_answer` reproduced
|
||||
live 2026-08-14 on "Chỉ định và chống chỉ định của Aspirin là gì?":
|
||||
`resolve()` silently picked one section, retrieval only fetched that
|
||||
one, and the still-broad question failed the completeness check against
|
||||
it. These pin that a genuine two-section question reports both, while a
|
||||
substring collision (the exact case `resolve()` itself guards against)
|
||||
still reports only one.
|
||||
"""
|
||||
|
||||
def test_two_genuinely_named_sections_both_reported(self) -> None:
|
||||
resolver = SectionResolver()
|
||||
matches = resolver.resolve_all(
|
||||
"Chỉ định và chống chỉ định của Aspirin là gì?"
|
||||
)
|
||||
assert {m.section_key for m in matches} == {"chi_dinh", "chong_chi_dinh"}
|
||||
|
||||
def test_substring_collision_is_not_double_counted(self) -> None:
|
||||
""""chỉ định" is a literal substring of "chống chỉ định" — this must
|
||||
stay a single match, exactly like `resolve()` already guarantees."""
|
||||
resolver = SectionResolver()
|
||||
matches = resolver.resolve_all("Chống chỉ định của aspirin là gì?")
|
||||
assert [m.section_key for m in matches] == ["chong_chi_dinh"]
|
||||
|
||||
def test_three_sections_named_at_once(self) -> None:
|
||||
resolver = SectionResolver()
|
||||
matches = resolver.resolve_all(
|
||||
"Liều dùng, chống chỉ định và tương tác thuốc của Metformin?"
|
||||
)
|
||||
assert {m.section_key for m in matches} == {
|
||||
"lieu_luong_va_cach_dung", "chong_chi_dinh", "tuong_tac_thuoc",
|
||||
}
|
||||
|
||||
def test_single_section_question_still_returns_one(self) -> None:
|
||||
resolver = SectionResolver()
|
||||
matches = resolver.resolve_all("Liều dùng metformin?")
|
||||
assert [m.section_key for m in matches] == ["lieu_luong_va_cach_dung"]
|
||||
|
||||
def test_unrecognised_question_returns_empty(self) -> None:
|
||||
assert SectionResolver().resolve_all("thuốc này giá bao nhiêu") == ()
|
||||
assert SectionResolver().resolve_all("") == ()
|
||||
|
||||
|
||||
class TestSectionRouting:
|
||||
def test_named_section_bypasses_similarity_entirely(self) -> None:
|
||||
retriever = SectionAwareRetriever(ALL_DOCS)
|
||||
|
||||
Reference in New Issue
Block a user