Remove chat rate limit

This commit is contained in:
2026-08-14 11:57:58 +07:00
parent d5ea65cd6e
commit 9be5819710
8 changed files with 260 additions and 40 deletions
+34 -2
View File
@@ -86,6 +86,30 @@ def test_drug_id_in_exact_underscore_form_resolves():
assert frame.unknown_drugs == ()
def test_golden_named_drug_section_overrides_a_misclassified_relation_frame():
"""Regression for the production failure observed through the real UI."""
understander = LlmQueryUnderstander(_FixedLlm({
"turn_type": "condition_relation",
"drugs": [],
"unknown_drugs": [],
"attribute": None,
"population": None,
"weight_kg": None,
"age_text": None,
"indication": None,
"condition_relation": "contraindication",
"needs_clarify": False,
"clarify_reason": None,
}), CATALOG, RESOLVER)
frame = understander.understand("Chống chỉ định của Paracetamol là gì?")
assert frame.turn_type == "drug_attribute"
assert frame.drugs == ("paracetamol_acetaminophen",)
assert frame.attribute == "chong_chi_dinh"
assert frame.needs_clarify is False
def test_exact_candidate_does_not_repeat_the_catalog_wide_fuzzy_scan():
resolver = _FakeResolver({"metformin": "metformin"})
understander = LlmQueryUnderstander(_FixedLlm({
@@ -220,6 +244,11 @@ def test_quick_replies_are_parsed_when_the_model_offers_them():
def test_quick_replies_are_dynamic_but_bounded_before_becoming_ui_chips():
# 19 distinct valid entries (after " Người lớn " / "người lớn" dedup
# and the non-string 12 are dropped) so the 18-item cap — one per
# monograph section, see rag/sections.py SECTION_ORDER — still trims
# the last one, not just the old 4-item cap.
extra = [f"Lựa chọn {i}" for i in range(6, 20)]
understander = LlmQueryUnderstander(_FixedLlm({
"turn_type": "dosing_calc", "drugs": ["paracetamol_acetaminophen"],
"unknown_drugs": [], "attribute": None, "population": None,
@@ -228,14 +257,17 @@ def test_quick_replies_are_dynamic_but_bounded_before_becoming_ui_chips():
"quick_replies": [
" Người lớn ", "người lớn", "Trẻ em", 12,
"Phụ nữ có thai", "Người cao tuổi", "Lựa chọn thứ năm",
*extra,
],
}), CATALOG, RESOLVER)
frame = understander.understand("liều paracetamol")
assert frame.quick_replies == (
"Người lớn", "Trẻ em", "Phụ nữ có thai", "Người cao tuổi"
assert len(frame.quick_replies) == 18
assert frame.quick_replies[:5] == (
"Người lớn", "Trẻ em", "Phụ nữ có thai", "Người cao tuổi", "Lựa chọn thứ năm"
)
assert "Lựa chọn 19" not in frame.quick_replies
def test_string_false_does_not_turn_into_a_clarification():