diff --git a/inquiry-agent/agent/policy/sea_text_flow.py b/inquiry-agent/agent/policy/sea_text_flow.py index b5db649..0cb52c2 100644 --- a/inquiry-agent/agent/policy/sea_text_flow.py +++ b/inquiry-agent/agent/policy/sea_text_flow.py @@ -165,6 +165,9 @@ class SeaTextInquiryFlow(AirTextInquiryFlow): inbound_raw=inbound_raw, ) + from agent.schema.sea_options import harvest_sea_class + + facts = harvest_sea_class(text, facts) check = validate_required_fields(facts=facts, business_line="SEA") facts = dict(check["facts"]) tms_ready = assemble_sea_query(facts) diff --git a/inquiry-agent/tests/test_attachment_inquiry.py b/inquiry-agent/tests/test_attachment_inquiry.py index 76870b3..096e444 100644 --- a/inquiry-agent/tests/test_attachment_inquiry.py +++ b/inquiry-agent/tests/test_attachment_inquiry.py @@ -47,6 +47,8 @@ SEA_ORAL = """海运 货量:20吨 整柜或拼柜:整柜 箱型箱量:1x40HQ +贸易条款:FOB +运输分类:Port to Port """ diff --git a/inquiry-agent/tests/test_image_inquiry.py b/inquiry-agent/tests/test_image_inquiry.py index 15293e0..bc350be 100644 --- a/inquiry-agent/tests/test_image_inquiry.py +++ b/inquiry-agent/tests/test_image_inquiry.py @@ -45,6 +45,8 @@ SEA_ORAL = """海运 货量:20吨 整柜或拼柜:整柜 箱型箱量:1x40HQ +贸易条款:FOB +运输分类:Port to Port """ LAND_ORAL = """陆运 diff --git a/inquiry-agent/tests/test_sea_text_inquiry.py b/inquiry-agent/tests/test_sea_text_inquiry.py index a8aa4b4..9b3aebb 100644 --- a/inquiry-agent/tests/test_sea_text_inquiry.py +++ b/inquiry-agent/tests/test_sea_text_inquiry.py @@ -40,6 +40,8 @@ COMPLETE_SEA = { "货量": "20吨", "整柜或拼柜": "整柜", "箱型箱量": "1x40HQ", + "贸易条款": "FOB", + "运输分类": "Port to Port", } @@ -257,7 +259,44 @@ class SeaTextInquiryTests(unittest.TestCase): self.assertIn("其他", text) self.assertIn("贸易条款:FOB", text) - def test_complete_sea_inquiry_card_uses_seven_fields(self) -> None: + def test_incomplete_without_trade_terms_does_not_create_ticket(self) -> None: + facts = dict(COMPLETE_SEA) + facts.pop("贸易条款") + phase = self.flow.on_text( + sender_id="s-miss", + text="海运缺条款", + reply=self._reply, + injected_facts=facts, + injected_mode="SEA", + ) + self.assertEqual(phase, "clarify") + self.assertIn("贸易条款", "\n".join(self.replies)) + self.assertFalse((self.flow.session_of("s-miss").work_order_no or "").startswith("WO")) + + def test_harvest_class_from_reply_then_quotes(self) -> None: + first = dict(COMPLETE_SEA) + first.pop("运输分类") + phase = self.flow.on_text( + sender_id="s-class", + text="先缺分类", + reply=self._reply, + injected_facts=first, + injected_mode="SEA", + ) + self.assertEqual(phase, "clarify") + self.replies.clear() + phase = self.flow.on_text( + sender_id="s-class", + text="Port to Port", + reply=self._reply, + injected_mode="SEA", + ) + self.assertEqual(phase, "wait_collab") + joined = "\n".join(self.replies) + self.assertIn("运输分类:Port to Port", joined) + self.assertIn("贸易条款:FOB", joined) + + def test_complete_sea_inquiry_card_uses_ten_fields(self) -> None: phase = self.flow.on_text( sender_id="s1", text="海运完整", @@ -273,6 +312,8 @@ class SeaTextInquiryTests(unittest.TestCase): self.assertIn("货物数量:20吨", joined) self.assertIn("整柜或拼柜:整柜", joined) self.assertIn("箱型箱量:1x40HQ", joined) + self.assertIn("贸易条款:FOB", joined) + self.assertIn("运输分类:Port to Port", joined) self.assertIn("正在查询TMS报价", joined) self.assertNotIn("件数:", joined.split("正在查询TMS报价")[0]) self.assertNotIn("本轮先开通空运", joined)