fix: stabilize dense-text rejection and serialize delayed image flush

This commit is contained in:
2026-02-28 20:00:59 +08:00
parent 52da73a07f
commit f411250a52
2 changed files with 16 additions and 3 deletions

View File

@@ -468,7 +468,12 @@ class QingjianAPIClient:
"""判断文本是否指代之前的图片(图一/图二/这张/那张/上面那张等)"""
if not msg:
return False
refs = ("图一", "图二", "第一张", "第二张", "这张", "那张", "上面那张", "下面那张", "刚才那张", "上一张", "下一张")
refs = (
"图一", "图二", "第一张", "第二张",
"这张", "那张", "这图", "那个图",
"这个", "这个呢",
"上面那张", "下面那张", "刚才那张", "上一张", "下一张",
)
return any(r in msg for r in refs)
def _extract_image_urls(self, msg: str) -> list:
@@ -612,7 +617,9 @@ class QingjianAPIClient:
old.cancel()
async def _delay_flush(capture_key, capture_data):
await asyncio.sleep(self._DEBOUNCE_SECONDS + 4)
await self._flush_pending_images(capture_key, capture_data)
# 与同客户 agent_reply 串行,避免“延迟报价”和“当前追问”并发打架
async with self._get_customer_lock(capture_key):
await self._flush_pending_images(capture_key, capture_data)
task = asyncio.create_task(_delay_flush(key, data))
self._pending_image_tasks[key] = task
return

View File

@@ -241,6 +241,7 @@ class ImageAnalyzer:
DENSE_TEXT_SUBJECT_KEYWORDS = (
"宣传栏", "公告栏", "展板", "海报墙", "通知栏", "知识栏", "制度牌", "公示栏", "墙报", "密密麻麻",
"宣传海报", "知识海报", "科普海报", "防灾减灾", "宣传板", "宣传页",
"表格", "检索表", "配伍表", "药物配伍", "课程表", "流程表", "说明表", "数据表",
"word wall", "poster wall", "bulletin board",
)
@@ -571,6 +572,10 @@ class ImageAnalyzer:
kw in scene_text
for kw in self.DENSE_TEXT_SUBJECT_KEYWORDS
)
dense_text_hint = any(
kw in scene_text
for kw in ("密集文字", "大量文字", "小字", "多板块", "细字")
)
# 校验比例合法性
valid_ratios = {"1:1", "9:16", "16:9", "3:4", "4:3", "3:2", "2:3", "5:4", "4:5"}
@@ -640,7 +645,8 @@ class ImageAnalyzer:
# 硬规则1文字很多>100且密密麻麻不接单
text_gt_100 = text_amount in ["大量 (51-200 字)", "极多 (200 字以上)"]
if text_gt_100 or dense_text_scene:
dense_text_hard_reject = text_gt_100 or dense_text_scene or (has_text == "yes" and dense_text_hint)
if dense_text_hard_reject:
feasibility = "no"
risk = "high"
note = "文字内容过于密集(如宣传栏/公告栏),暂不接单处理"