Remove chat rate limit
This commit is contained in:
@@ -30,7 +30,7 @@ from .routing import QueryRoutingService
|
||||
# be different prompts (or a different judge) to be independent evidence —
|
||||
# see this function's own reasoning above.
|
||||
|
||||
_QUICK_REPLY_MAX_ITEMS = 4
|
||||
_QUICK_REPLY_MAX_ITEMS = 18 # one per monograph section (see rag/sections.py SECTION_ORDER)
|
||||
_QUICK_REPLY_MAX_CHARS = 40
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -207,6 +207,29 @@ class _VerificationOutcome:
|
||||
missing: tuple[str, ...] = ()
|
||||
|
||||
|
||||
# Display-only label override, 2026-08-13: these 3 of 684 catalog drug_ids are
|
||||
# missing the letter for "Đ"/"đ" entirely (ingestion's slug generator drops it
|
||||
# instead of mapping it to "d" like every other Vietnamese diacritic), so
|
||||
# `drug_id.replace("_", " ").upper()` can never reconstruct the accented name
|
||||
# and the fold-based dedup below always mismatches for them. Does not touch
|
||||
# drug_id or any stored data — only the label text shown in generated answers.
|
||||
_DRUG_LABEL_OVERRIDES: dict[str, str] = {
|
||||
"giai_oc_to_uon_van_hap_phu_vac_xin_uon_van_hap_phu":
|
||||
"GIẢI ĐỘC TỐ UỐN VÁN HẤP PHỤ (VẮC XIN UỐN VÁN HẤP PHỤ)",
|
||||
"khang_oc_to_bach_hau": "KHÁNG ĐỘC TỐ BẠCH HẦU",
|
||||
"thuoc_uong_bu_nuoc_va_ien_giai": "THUỐC UỐNG BÙ NƯỚC VÀ ĐIỆN GIẢI",
|
||||
}
|
||||
|
||||
|
||||
def _fold_diacritics(text: str) -> str:
|
||||
"""Accent-insensitive fold. Vietnamese "Đ"/"đ" is not a combining-mark
|
||||
decomposition under NFKD (unlike every other Vietnamese diacritic), so it
|
||||
survives the strip below unless mapped explicitly first."""
|
||||
text = text.replace("Đ", "D").replace("đ", "d")
|
||||
stripped = unicodedata.normalize("NFKD", text)
|
||||
return "".join(ch for ch in stripped if not unicodedata.combining(ch)).casefold()
|
||||
|
||||
|
||||
def _parse_claims(
|
||||
raw_claims: list, *, include_drug_label: bool = False
|
||||
) -> tuple[tuple[str, tuple[int, ...]], ...] | None:
|
||||
@@ -230,8 +253,8 @@ def _parse_claims(
|
||||
drug_id = item.get("drug_id")
|
||||
if not isinstance(drug_id, str) or not drug_id.strip():
|
||||
return None
|
||||
label = drug_id.replace("_", " ").upper()
|
||||
if label.casefold() not in cleaned.casefold():
|
||||
label = _DRUG_LABEL_OVERRIDES.get(drug_id) or drug_id.replace("_", " ").upper()
|
||||
if _fold_diacritics(label) not in _fold_diacritics(cleaned):
|
||||
cleaned = f"{label}: {cleaned}"
|
||||
claims.append((cleaned, tuple(citations)))
|
||||
return tuple(claims)
|
||||
|
||||
Reference in New Issue
Block a user