Claude Claude Opus 5.5 commited on
Commit
07c68fe
·
unverified ·
1 Parent(s): ba2260c

ค้นตามงานใช้: กรองรายรุ่นด้วยคู่ รุ่น×อุตสาหกรรม×งาน (เปิดพร้อม FRONT_INTERPRETER=llm)

Browse files

แก้หลังเห็นผล blind (BL-023): router.match_application กรองอุตสาหกรรมที่ระดับแถวของ
application_material_index แต่แถวเดียวรวม belt_codes ของทุกอุตสาหกรรมที่ใช้งานนั้น
"จัดเรียงพาเลท ผักผลไม้" จึงได้ 13 รุ่น (ของบรรจุภัณฑ์ปน 7) · ฐานมี 6
- _belt_app_in: ตรวจ industries[].applications[] ของรุ่นนั้นว่าเล่มผูกงานนี้ในอุตสาหกรรมนี้จริง
- ทางกราฟ (graph_application_match) กรองถูกอยู่แล้ว ไม่แตะ · agent ใช้ router ตัวเดียวกัน (เปิดเมื่อ env ตั้งเท่านั้น)
- ผลกับชุดเดิม (เล่นบทสนทนาจริง + build_modutech_turn เปิด/ปิด): 136 · testsuite_120 · graph_apps ไม่เปลี่ยน ·
conv_leaks เปลี่ยน 2 เทิร์น (CONV-13 t4 20→18 · CONV-26 t5 15→9 รุ่น ตัดรุ่นนอกอุตสาหกรรมไก่) ทั้งสองเทิร์นไม่มีเกณฑ์รายชื่อ
- test_front_interpreter 38/38 (+3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GwsdogGsnbFRJYfG8rdbzK

brands/modutech/router.py CHANGED
@@ -8,6 +8,7 @@ resolve รหัสแบบ exact ก่อน vector search · ค้นท
8
  """
9
  from __future__ import annotations
10
 
 
11
  import re
12
  from dataclasses import dataclass, field
13
  from typing import Optional
@@ -359,6 +360,11 @@ class CatalogueSearch:
359
  if use_industry and industry and industry not in (e.get("industries") or []):
360
  continue
361
  for c in e["belt_codes"]:
 
 
 
 
 
362
  # ตรวจรายรุ่นทุกแถว — เดิมเชื่อธง manufactured ของแถว แต่ธงเป็น "mixed" ได้
363
  # (ทั้งแถวผลิต-ไม่ผลิตปนกัน) ผลคือบอกเกรดที่รุ่นนั้นไม่ได้ผลิต แล้ว note_th ยังบอก
364
  # LLM ว่า "ผลิตจริง" (AP-006 MD254 GT POM · AP-007 SM127 FG PE — 10 ต.ค.)
@@ -389,6 +395,12 @@ class CatalogueSearch:
389
  {k: sorted(v) for k, v in sorted(by_belt.items())}, filtered,
390
  {k: v for k, v in sorted(notes.items()) if k in by_belt})
391
 
 
 
 
 
 
 
392
  def match_industry(self, text: str) -> Optional[tuple[str, dict[str, list[dict]]]]:
393
  """อุตสาหกรรมจากคำในคำถาม → ทุกรุ่นที่เล่มผูกกับอุตสาหกรรมนั้น พร้อมงานใช้ + เกรดตามเล่ม
394
 
@@ -594,6 +606,11 @@ APPLICATION_KEYWORDS: dict[str, list[str]] = {
594
  "dressing": ["ตกแต่งชิ้นเนื้อ"], "conditioning": ["ปรับสภาพ"], "filling": ["เข้าเครื่องบรรจุ", "filling"],
595
  "warehouse": ["คลังสินค้า", "warehouse"],
596
  }
 
 
 
 
 
597
  INDUSTRY_KEYWORDS: dict[str, list[str]] = {
598
  "Poultry": ["ไก่", "สัตว์ปีก", "เป็ด", "poultry", "chicken"],
599
  "Meat Processing": ["หมู", "เนื้อวัว", "เนื้อสัตว์", "meat", "pork", "beef"],
 
8
  """
9
  from __future__ import annotations
10
 
11
+ import os
12
  import re
13
  from dataclasses import dataclass, field
14
  from typing import Optional
 
360
  if use_industry and industry and industry not in (e.get("industries") or []):
361
  continue
362
  for c in e["belt_codes"]:
363
+ # 3 พ.ย. (หลังเห็น blind BL-023): แถวของดัชนีรวม belt_codes ของทุกอุตสาหกรรมในแถว
364
+ # ("จัดเรียงพาเลท" ผักผลไม้ ได้รุ่นของบรรจุภัณฑ์ปนมา 7 รุ่น) → ตรวจคู่ รุ่น×อุตสาหกรรม×งาน รายรุ่น
365
+ # เปิดพร้อม FRONT_INTERPRETER=llm · ปิด = ผลเดิมทุกตัวอักษร
366
+ if use_industry and industry and _strict_industry() and not self._belt_app_in(c, industry, app):
367
+ continue
368
  # ตรวจรายรุ่นทุกแถว — เดิมเชื่อธง manufactured ของแถว แต่ธงเป็น "mixed" ได้
369
  # (ทั้งแถวผลิต-ไม่ผลิตปนกัน) ผลคือบอกเกรดที่รุ่นนั้นไม่ได้ผลิต แล้ว note_th ยังบอก
370
  # LLM ว่า "ผลิตจริง" (AP-006 MD254 GT POM · AP-007 SM127 FG PE — 10 ต.ค.)
 
395
  {k: sorted(v) for k, v in sorted(by_belt.items())}, filtered,
396
  {k: v for k, v in sorted(notes.items()) if k in by_belt})
397
 
398
+ def _belt_app_in(self, code: str, industry: str, app: str) -> bool:
399
+ """เล่มผูกรุ่นนี้กับงานนี้ในอุตสาหกรรมนี้จริง (industries[].applications[].application)"""
400
+ p = self.cat.by_code.get(code) or {}
401
+ return any(i.get("industry") == industry and any(a.get("application") == app for a in i.get("applications") or [])
402
+ for i in p.get("industries") or [])
403
+
404
  def match_industry(self, text: str) -> Optional[tuple[str, dict[str, list[dict]]]]:
405
  """อุตสาหกรรมจากคำในคำถาม → ทุกรุ่นที่เล่มผูกกับอุตสาหกรรมนั้น พร้อมงานใช้ + เกรดตามเล่ม
406
 
 
606
  "dressing": ["ตกแต่งชิ้นเนื้อ"], "conditioning": ["ปรับสภาพ"], "filling": ["เข้าเครื่องบรรจุ", "filling"],
607
  "warehouse": ["คลังสินค้า", "warehouse"],
608
  }
609
+ def _strict_industry() -> bool:
610
+ """กรองรายรุ่นด้วยคู่ รุ่น×อุตสาหกรรม×งาน (3 พ.ย.) — เปิดพร้อม FRONT_INTERPRETER=llm"""
611
+ return (os.getenv("FRONT_INTERPRETER") or "rules").strip().lower() == "llm"
612
+
613
+
614
  INDUSTRY_KEYWORDS: dict[str, list[str]] = {
615
  "Poultry": ["ไก่", "สัตว์ปีก", "เป็ด", "poultry", "chicken"],
616
  "Meat Processing": ["หมู", "เนื้อวัว", "เนื้อสัตว์", "meat", "pork", "beef"],
test_front_interpreter.py CHANGED
@@ -208,5 +208,35 @@ ok("ปิด FRONT_INTERPRETER → ผลค้นเดิม (ไม่กร
208
  ctx is None or ("matched_before_temperature" not in ctx["search_result"] and "need_filter" not in ctx),
209
  d.action)
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  print(f"\nรวม {passed}/{passed + failed}")
212
  sys.exit(1 if failed else 0)
 
208
  ctx is None or ("matched_before_temperature" not in ctx["search_result"] and "need_filter" not in ctx),
209
  d.action)
210
 
211
+ print("8) งานใช้ × อุตสาหกรรม กรองรายรุ่น (3 พ.ย. · router.match_application)")
212
+ S8 = CatalogueSearch(cat)
213
+
214
+
215
+ def app_codes(text, on):
216
+ os.environ["FRONT_INTERPRETER"] = "llm" if on else "rules"
217
+ try:
218
+ m = S8.match_application(text)
219
+ return (m.industry, m.belt_codes) if m else (None, [])
220
+ finally:
221
+ os.environ.pop("FRONT_INTERPRETER", None)
222
+
223
+
224
+ def truth(industry_th, app_th):
225
+ return sorted(p["belt_code"] for p in cat.products for i in p.get("industries") or []
226
+ if i.get("industry_th") == industry_th
227
+ and any(a.get("application_th") == app_th for a in i.get("applications") or []))
228
+
229
+
230
+ T8 = "งานจัดเรียงพาเลท ผักผลไม้ ใช้สายพานรุ่นไหน"
231
+ ind_off, off = app_codes(T8, False)
232
+ ind_on, on = app_codes(T8, True)
233
+ want = truth("ผักและผลไม้", "การจัดเรียงและรื้อพาเลท")
234
+ ok("ปิด: ได้รุ่นของอุตสาหกรรมอื่นปน (พฤติกรรมเดิม)", set(want) < set(off), (len(want), len(off)))
235
+ ok("เปิด: ได้เฉพาะรุ่นที่เล่มผูกกับงานนี้ในผักผลไม้", ind_on == "Fruit & Vegetable" and sorted(on) == want, (on, want))
236
+ _, pk = app_codes("สายพานจัดเรียงพาเลท บรรจุภัณฑ์", True)
237
+ # ทุกรุ่นต้องเป็นของบรรจุภัณฑ์จริง (router ตัดรุ่นที่ไม่ผลิตเกรดที่เล่มแนะนำออกอีกชั้น เช่น XP254 EVO FLT)
238
+ pk_truth = sorted(set(truth("บรรจุภัณฑ์", "การจัดเรียงและรื้อพาเลท")) | set(truth("บรรจุภัณฑ์", "เครื่องจัดเรียงพาเลท")))
239
+ ok("อุตสาหกรรมอื่นยังได้รายชื่อของตัวเอง (ทุกรุ่นเป็นของบรรจุภัณฑ์)", pk and set(pk) <= set(pk_truth), (pk, pk_truth))
240
+
241
  print(f"\nรวม {passed}/{passed + failed}")
242
  sys.exit(1 if failed else 0)