落地私聊空运询价与TMS报价回填,按后台模板出单。
查到价后把币种、单位、数量、单价、备注写入报价单,避免销售只看到光秃秃的金额。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,7 +27,7 @@ class ChannelRuntime:
|
||||
企微通道运行时:inbox/outbox 各一条守护线程。
|
||||
|
||||
启动时机:FastAPI lifespan;停止:进程退出。
|
||||
inbox:IntentRouter.route(默认 stub)→ dispatch 查表;无业务分支森林。
|
||||
inbox:自由文字走 DeepSeek A 认意图(本线程,非回调);点卡不进模型。
|
||||
"""
|
||||
|
||||
def __init__(self, settings: Settings) -> None:
|
||||
@@ -35,7 +35,8 @@ class ChannelRuntime:
|
||||
self._store = get_message_store()
|
||||
self._stop = threading.Event()
|
||||
self._threads: list[threading.Thread] = []
|
||||
self._router = IntentRouter(allow_network=False)
|
||||
# 开网后销售原话交给模型认「续办/新询价」;未开网才走 stub。
|
||||
self._router = IntentRouter(allow_network=bool(settings.llm_allow_network))
|
||||
agent_id = int(settings.wecom_agent_id or "0") or 0
|
||||
self._client = WeComAppClient(
|
||||
corp_id=settings.wecom_corp_id,
|
||||
@@ -68,11 +69,13 @@ class ChannelRuntime:
|
||||
self._store.wait_inbox(1.0)
|
||||
continue
|
||||
try:
|
||||
decision = self._router.route(
|
||||
text=item.message.content or "",
|
||||
sender_id=item.message.sender_id or "",
|
||||
message = item.message
|
||||
decision = self._router.route_inbound(
|
||||
text=message.content or "",
|
||||
sender_id=message.sender_id or "",
|
||||
event=str((message.raw or {}).get("event") or ""),
|
||||
)
|
||||
dispatch_inbound(item.message, decision)
|
||||
dispatch_inbound(message, decision)
|
||||
self._store.complete_inbound(item.id)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.exception("inbox 处理失败 id=%s", item.id)
|
||||
@@ -91,7 +94,11 @@ class ChannelRuntime:
|
||||
logger.warning("outbox 过期丢弃 id=%s", item.id)
|
||||
self._store.complete_outbound(item.id)
|
||||
continue
|
||||
result = self._client.send_text(touser=item.touser, content=item.content)
|
||||
result = self._client.send_outbound(
|
||||
touser=item.touser,
|
||||
content=item.content,
|
||||
payload=getattr(item, "payload", None) or {},
|
||||
)
|
||||
if result.ok:
|
||||
self._store.complete_outbound(item.id)
|
||||
elif result.errcode in PERMANENT_SEND_ERRORS:
|
||||
|
||||
Reference in New Issue
Block a user