调价后的新价格写入报价单;多段段前的货物带到各段,协同群不再把体积里的星号吃掉。海运字段齐了先核对再查价。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-03 22:39:54 +08:00
co-authored by Cursor
parent 0a14b4cc15
commit 7c77e45e03
32 changed files with 1384 additions and 75 deletions
+39
View File
@@ -59,6 +59,37 @@ class OralExtractTests(unittest.TestCase):
out = invoke_shell(payload={"a": 1})
self.assertEqual(out.get("error"), "extract_fields_shell_not_implemented")
def test_city_pair_without_mode_does_not_default_air(self) -> None:
"""没写运输方式时,模型猜的空运不能当成已选。港口和日期仍留下。"""
text = "查一下10月9日郑州-吉隆坡的报价"
guessed = parse_extract_payload(
{
"transport_mode": "AIR",
"fields": {
"起运港": "郑州",
"目的港": "吉隆坡",
"报价日期": "2026-10-09",
},
}
)
snap = extract_inquiry_snapshot(text, b_result=guessed)
self.assertEqual(snap["business_line"], "")
self.assertEqual(snap["facts"].get("起运港"), "郑州")
self.assertEqual(snap["facts"].get("目的港"), "吉隆坡")
self.assertEqual(snap["facts"].get("报价日期"), "2026-10-09")
flow = AirTextInquiryFlow(MemoryLedger())
replies: list[str] = []
phase = flow.on_text(
sender_id="u-mode",
text=text,
reply=lambda body, extra=None: replies.append(body),
b_result=guessed,
allow_b=False,
)
self.assertEqual(phase, "need_mode")
self.assertTrue(any("告知我询价的运输方式" in x for x in replies))
self.assertFalse(any(x.startswith("运输方式:空运") or "运输方式:空运" in x for x in replies))
def test_oral_snapshot_uses_b_not_regex(self) -> None:
snap = extract_inquiry_snapshot(ORAL, b_result=parse_extract_payload(B_JSON))
self.assertEqual(snap["business_line"], "AIR")
@@ -304,6 +335,14 @@ class OralExtractTests(unittest.TestCase):
self.assertIn("重量(KG):1.5KG", shown)
self.assertNotIn("1.5KGS", shown)
def test_dimension_text_is_volume_without_multiplying(self) -> None:
from agent.schema.field_validate import harvest_oral_measures
facts = harvest_oral_measures("茶叶,1.1*2.1*2.2,11kg,21件", {})
self.assertEqual(facts["体积"], "1.1*2.1*2.2")
self.assertEqual(facts["毛重"], "11kg")
self.assertEqual(facts["件数"], "21件")
def test_oral_units_fill_weight_volume_without_b(self) -> None:
snap = extract_inquiry_snapshot(
"珠海到克拉克空运,茶叶 10件 100KGS 2CBM 托盘"