Skip to content

Fix #7: answer drug questions and extract known names in structured queries - #14

Open
xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-7-drug-query
Open

xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-7-drug-query

Conversation

@xiaoyao-666-coder

Copy link
Copy Markdown

Closes #7. 两处“听不懂用户问法”的问题。

A. 用药问题:根因不是知识库缺资料(布洛芬文档一直都在),而是意图识别:drug 关键词里既没有药品名也没有“怎么吃”这类用法词,“布洛芬怎么吃?有什么注意事项?”因含“注意事项”被判为 faq,而检索按 category == intent 硬过滤,drug 文档被排除 → 0 引用 → 通用引导。

  • drug 关键词增加“怎么吃/如何服用/用量/能吃吗”等用法词;命中知识库 drug 文档派生的药品名时 drug 计分;安全白名单增加裸“不”,使“不自行停药”这类禁止性表述不再被安全审查误拦。布洛芬文档本身没有剂量数据,回答如实引用“具体剂量和疗程以当前药品说明书及医生或药师建议为准”,不编造剂量。

B. 结构化查询抽词:_extract_term 按白名单表里已登记的实体名做最长匹配(如“布洛芬”←“布洛芬缓释胶囊”),仍保持 LIKE 前缀可走索引;匹配不到已知实体时返回 blocked + 澄清(能抽出用户写的词时点名澄清),不再返回“0 行假装没货”。注入防护未放松。

验证:新增 backend/tests/test_drug_query.py(18 个测试);MEDGUIDE_MODE=test python -m pytest -q backend/tests 539 passed(基线 521 + 18 新);前端未改动。

已知未动:修前就有的“发烧怎么退热”判 unknown、“怎么止痛”0 引用,未顺手改。

… structured queries

- Drug intent: add usage phrasing (怎么吃/如何服用/用量/能吃吗...) to
  drug keywords and score drug intent on known drug names derived
  from knowledge-base drug documents, so '布洛芬怎么吃?有什么注意
  事项?' is no longer misrouted to faq with zero citations. Also
  allow bare negated safety phrasing ('不自行停药') in the safe
  output whitelist to stop false-positive safety blocks.
- Structured queries: _extract_term now longest-matches against
  registered entity names from the whitelisted tables; unknown
  entities return blocked with a clarification instead of an empty
  result that reads as 'out of stock'. Injection guards unchanged.
- Add backend/tests/test_drug_query.py (18 tests).

Closes zhengdaodeguL#7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][中] 用药问题得不到回答;结构化查询抽词把口语问法抽成查不到的前缀

1 participant