feat: 海运私聊收齐贸易条款和运输分类再查价
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -165,6 +165,9 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
|
|||||||
inbound_raw=inbound_raw,
|
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")
|
check = validate_required_fields(facts=facts, business_line="SEA")
|
||||||
facts = dict(check["facts"])
|
facts = dict(check["facts"])
|
||||||
tms_ready = assemble_sea_query(facts)
|
tms_ready = assemble_sea_query(facts)
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ SEA_ORAL = """海运
|
|||||||
货量:20吨
|
货量:20吨
|
||||||
整柜或拼柜:整柜
|
整柜或拼柜:整柜
|
||||||
箱型箱量:1x40HQ
|
箱型箱量:1x40HQ
|
||||||
|
贸易条款:FOB
|
||||||
|
运输分类:Port to Port
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ SEA_ORAL = """海运
|
|||||||
货量:20吨
|
货量:20吨
|
||||||
整柜或拼柜:整柜
|
整柜或拼柜:整柜
|
||||||
箱型箱量:1x40HQ
|
箱型箱量:1x40HQ
|
||||||
|
贸易条款:FOB
|
||||||
|
运输分类:Port to Port
|
||||||
"""
|
"""
|
||||||
|
|
||||||
LAND_ORAL = """陆运
|
LAND_ORAL = """陆运
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ COMPLETE_SEA = {
|
|||||||
"货量": "20吨",
|
"货量": "20吨",
|
||||||
"整柜或拼柜": "整柜",
|
"整柜或拼柜": "整柜",
|
||||||
"箱型箱量": "1x40HQ",
|
"箱型箱量": "1x40HQ",
|
||||||
|
"贸易条款": "FOB",
|
||||||
|
"运输分类": "Port to Port",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,7 +259,44 @@ class SeaTextInquiryTests(unittest.TestCase):
|
|||||||
self.assertIn("其他", text)
|
self.assertIn("其他", text)
|
||||||
self.assertIn("贸易条款:FOB", 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(
|
phase = self.flow.on_text(
|
||||||
sender_id="s1",
|
sender_id="s1",
|
||||||
text="海运完整",
|
text="海运完整",
|
||||||
@@ -273,6 +312,8 @@ class SeaTextInquiryTests(unittest.TestCase):
|
|||||||
self.assertIn("货物数量:20吨", joined)
|
self.assertIn("货物数量:20吨", joined)
|
||||||
self.assertIn("整柜或拼柜:整柜", joined)
|
self.assertIn("整柜或拼柜:整柜", joined)
|
||||||
self.assertIn("箱型箱量:1x40HQ", joined)
|
self.assertIn("箱型箱量:1x40HQ", joined)
|
||||||
|
self.assertIn("贸易条款:FOB", joined)
|
||||||
|
self.assertIn("运输分类:Port to Port", joined)
|
||||||
self.assertIn("正在查询TMS报价", joined)
|
self.assertIn("正在查询TMS报价", joined)
|
||||||
self.assertNotIn("件数:", joined.split("正在查询TMS报价")[0])
|
self.assertNotIn("件数:", joined.split("正在查询TMS报价")[0])
|
||||||
self.assertNotIn("本轮先开通空运", joined)
|
self.assertNotIn("本轮先开通空运", joined)
|
||||||
|
|||||||
Reference in New Issue
Block a user