fix: disable legacy fast quote path and tighten dense-text rejection
This commit is contained in:
@@ -1342,12 +1342,19 @@ class CustomerServiceAgent:
|
||||
try:
|
||||
from utils.content_filter import should_block_customer
|
||||
if should_block_customer(message.msg) or self._is_political_inquiry(message.msg):
|
||||
# 命中敏感询问时清空待报价队列,避免旧图残留污染后续会话
|
||||
state.pending_image_urls.clear()
|
||||
state.pending_requirements.clear()
|
||||
self._sync_pending_quote_state(message.from_id, state)
|
||||
reply = "这类不做哈,政治相关图片和人物都不接。"
|
||||
state.last_reply_at = datetime.now()
|
||||
print(f"{self.C_REPLY}[REPLY->CUSTOMER]{self.C_RESET} {reply}")
|
||||
return AgentResponse(reply=reply, should_reply=True, need_transfer=False)
|
||||
except Exception:
|
||||
if self._is_political_inquiry(message.msg):
|
||||
state.pending_image_urls.clear()
|
||||
state.pending_requirements.clear()
|
||||
self._sync_pending_quote_state(message.from_id, state)
|
||||
reply = "这类不做哈,政治相关图片和人物都不接。"
|
||||
state.last_reply_at = datetime.now()
|
||||
print(f"{self.C_REPLY}[REPLY->CUSTOMER]{self.C_RESET} {reply}")
|
||||
|
||||
@@ -98,6 +98,8 @@ class QingjianAPIClient:
|
||||
self._agent_semaphore = asyncio.Semaphore(8)
|
||||
self._pending_images: dict = {}
|
||||
self._pending_image_tasks: dict = {}
|
||||
# 旧版“看图即报价”快速链路(默认关闭,避免与 Agent 批量收集逻辑并发打架)
|
||||
self._legacy_fast_quote_enabled = os.getenv("LEGACY_FAST_IMAGE_QUOTE", "false").lower() in ("1", "true", "yes")
|
||||
self._system_inquiry_rules = self._load_system_inquiry_rules()
|
||||
self._last_reply_sent_at: dict = {} # customer_key -> monotonic ts
|
||||
self._inbound_log_seen: dict = {} # signature -> monotonic ts(防重复写入)
|
||||
@@ -600,6 +602,7 @@ class QingjianAPIClient:
|
||||
_cid = data.get('from_id', '')
|
||||
_name = self.to_chinese(data.get('from_name', '') or data.get('cy_name', ''))
|
||||
_plat = data.get('acc_type', '')
|
||||
_shop_type = _get_shop_type(data.get('acc_id', ''), self.to_chinese(data.get('goods_name', '') or ''))
|
||||
|
||||
# 超大尺寸(米制)直接拒单,避免进入报价/处理流程
|
||||
oversize_reply = self._oversize_reply_if_needed(msg_text)
|
||||
@@ -607,6 +610,8 @@ class QingjianAPIClient:
|
||||
await self.send_reply(data, oversize_reply)
|
||||
return
|
||||
|
||||
# 找图/修图店铺:统一走 Agent 的“收集需求后统一报价”流程,避免按单图快速报价
|
||||
if self._legacy_fast_quote_enabled and _shop_type != "find_image":
|
||||
# 消息含图片URL:累积到待处理列表,先询问要求
|
||||
if self._msg_has_image_url(msg_text):
|
||||
urls = self._extract_image_urls(msg_text)
|
||||
|
||||
@@ -579,7 +579,7 @@ class ImageAnalyzer:
|
||||
)
|
||||
dense_text_hint = any(
|
||||
kw in scene_text
|
||||
for kw in ("密集文字", "大量文字", "小字", "多板块", "细字")
|
||||
for kw in ("密集文字", "大量文字", "多板块")
|
||||
)
|
||||
|
||||
# 校验比例合法性
|
||||
|
||||
Reference in New Issue
Block a user