机器人显示名与站点标题可配;多段联运列表投影;协同群监听对账;工单附件落存;模板与工单后台补强

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
linmianxun
2026-10-19 09:41:59 +08:00
co-authored by Cursor
parent 277cdc1c28
commit 2b528758b4
119 changed files with 6760 additions and 3516 deletions
+35 -71
View File
@@ -367,7 +367,12 @@ def land_confirm_card(facts: dict[str, str] | None) -> str:
]
for key in _land_cargo_keys(land_type, src):
label = LAND_DISPLAY.get(key, key)
val = (src.get(key) or "").strip()
if key == "品名":
from agent.schema.land_options import land_cargo_name
val = land_cargo_name(src)
else:
val = (src.get(key) or "").strip()
lines.append(f"{label}(必填):{val}")
if land_type in _LAND_CUSTOMS_TYPES:
lines.append(f"通关口岸(非必填):{(src.get('通关口岸') or '').strip()}")
@@ -534,7 +539,10 @@ def _air_known_value(facts: dict[str, str], key: str) -> str:
if key == "包装方式":
return (src.get("包装方式") or src.get("包装类型") or "").strip()
if key == "报价日期":
return (src.get("报价日期") or "").strip()
from agent.schema.field_validate import is_blank_quote_date
val = (src.get("报价日期") or "").strip()
return "" if is_blank_quote_date(val) else val
from agent.llm.extract_text import clip_inquiry_value
return clip_inquiry_value(src.get(key) or "")
@@ -650,42 +658,6 @@ def ask_clarify(
if key == "起运港":
continue
val = known(src, key)
# #region agent log
if key == "added_services":
try:
import json as _dbg_json
import time as _dbg_time
from pathlib import Path as _DbgPath
_payload = {
"sessionId": "5ea5b3",
"runId": "post-fix",
"hypothesisId": "H3",
"location": "inquiry_copy.py:ask_clarify",
"message": "clarify display added_services",
"data": {
"raw_facts": str(src.get("added_services") or ""),
"display_val": val,
"label": label,
},
"timestamp": int(_dbg_time.time() * 1000),
}
for _p in (
_DbgPath(__file__).resolve().parents[3] / "debug-5ea5b3.log",
_DbgPath(r"d:/own/友通达询价智能体(新)/debug-5ea5b3.log"),
_DbgPath(r"C:/Users/ytd_extdev_0903/incoming/debug-5ea5b3.log"),
):
try:
_p.parent.mkdir(parents=True, exist_ok=True)
with _p.open("a", encoding="utf-8") as _f:
_f.write(
_dbg_json.dumps(_payload, ensure_ascii=False) + "\n"
)
except Exception:
pass
except Exception:
pass
# #endregion
if val:
lines.append(f"{label}:{val}")
lines.append("")
@@ -802,10 +774,13 @@ def inquiry_field_lines(
dest = (facts.get("目的港") or facts.get("目的地") or "-").strip()
cargo = (facts.get("品名") or "-").strip() or "-"
pack = (facts.get("包装方式") or facts.get("包装类型") or "-").strip() or "-"
from agent.schema.field_validate import is_blank_quote_date
quote_date = (facts.get("报价日期") or "").strip()
if quote_date in {"-", "—", "-"}:
if is_blank_quote_date(quote_date):
quote_date = ""
if (transport_mode or "").strip() == "海运":
mode = (transport_mode or "").strip()
if mode == "海运":
qty = (facts.get("货量") or facts.get("货物数量") or "-").strip() or "-"
load = (facts.get("整柜或拼柜") or "-").strip() or "-"
box = (facts.get("箱型箱量") or "-").strip() or "-"
@@ -824,7 +799,7 @@ def inquiry_field_lines(
f"运输分类:{klass}",
f"报价日期:{quote_date or '-'}",
]
if (transport_mode or "").strip() == "陆运":
if mode == "陆运":
land_type = (facts.get("运输类型") or "").strip()
lines = [
f"工单号:{work_order_no}",
@@ -854,30 +829,6 @@ def inquiry_field_lines(
]
# 建单确认和空运群:有内容才多一行。没填不出现。核对卡的空行不在这里。
added = (facts.get("added_services") or facts.get("增值服务") or "").strip()
# #region agent log
try:
import json as _dbg_json
import time as _dbg_time
from pathlib import Path as _DbgPath
_payload = {
"sessionId": "5ea5b3",
"runId": "pre-fix",
"hypothesisId": "H3",
"location": "inquiry_copy.py:air_confirm_lines",
"message": "display added_services value",
"data": {
"added": added,
"facts_keys": sorted(str(k) for k in (facts or {}).keys()),
},
"timestamp": int(_dbg_time.time() * 1000),
}
_path = _DbgPath(__file__).resolve().parents[3] / "debug-5ea5b3.log"
with _path.open("a", encoding="utf-8") as _f:
_f.write(_dbg_json.dumps(_payload, ensure_ascii=False) + "\n")
except Exception:
pass
# #endregion
if added and added not in {"-", "—", "-"}:
lines.insert(-1, f"增值服务:{added}")
return lines
@@ -1323,18 +1274,21 @@ def collab_hint(work_order_no: str) -> str:
"""
空运价格卡协同说明:紧挨「不需要协同,直接生成报价单」上方。
后台 inquiring.air_collab_hint;库内模板可用 {{ticket_no}}。
无后台模板时用本默认句(已带工单号)。销售侧示例:
…发送“ WO202610060030@询价小助手”,谢谢。
后台 inquiring.air_collab_hint;库内模板可用 {{ticket_no}}、{{bot_name}}。
无后台模板时用本默认句(已带工单号与当前显示名)。
"""
from agent.policy.bot_name import bot_display_name
no = (work_order_no or "").strip()
name = bot_display_name()
return _r(
"inquiring.air_collab_hint",
(
f"若需要咨询内部航线人员,请手动将相关方拉到空运原有协同群,"
f"并在空运协同群中发送“ {no}@询价小助手”,谢谢。"
f"并在空运协同群中发送“ {no}@{name}”,谢谢。"
),
ticket_no=no,
bot_name=name,
)
@@ -2865,10 +2819,18 @@ def deal_ack(
next_followup_at: str = "",
lost_reason: str = "",
followup_hours: float | None = None,
business_line: str = "",
) -> str:
"""成交三态回执。后台 deal.recorded_won / lost.ask_reason / negotiating.recorded。"""
"""
成交三态回执。后台 deal.recorded_won / lost.ask_reason / negotiating.recorded。
多段联运不锁舱:已成交只回短确认,不要后台模板里「空运可锁舱」括号说明。
"""
no = (work_order_no or "").strip()
line = (business_line or "").strip().upper()
if outcome == "已成交":
if line == "MULTI":
return f"工单 {no} 已记录为「已成交」。"
return _r(
"deal.recorded_won",
f"已记录为「已成交」。工单 {no} 已关闭智能体跟进。",
@@ -3408,8 +3370,10 @@ def air_text_quote_for_lock_example(work_order_no: str = "") -> str:
附件报价不拆金额、常锁不成;产品口径改为引导航线改发文字价。
示例必须带计费单位(空运常见 KG),避免航线漏写单位导致文字价无法落库。
"""
from agent.policy.bot_name import at_bot
no = (work_order_no or "").strip() or "工单号"
return f"{no},空运段,KG,空运费 单价CNY99.00,数量100 ,金额CNY9900.00@询价小助手"
return f"{no},空运段,KG,空运费 单价CNY99.00,数量100 ,金额CNY9900.00{at_bot()}"
def air_attachment_quote_lock_tip(*, work_order_no: str) -> str: