From 08342c37ecca9c1d897c23d6ba8c9db959d8a865 Mon Sep 17 00:00:00 2001 From: jimi <1847930177@qq.com> Date: Sat, 28 Feb 2026 22:21:37 +0800 Subject: [PATCH] fix: use single-image wording for 1-image quote flow --- core/pydantic_ai_agent.py | 13 +++++++++++++ tests/test_batch_quote_reply_format.py | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/core/pydantic_ai_agent.py b/core/pydantic_ai_agent.py index a3d9e01..d938437 100755 --- a/core/pydantic_ai_agent.py +++ b/core/pydantic_ai_agent.py @@ -2019,6 +2019,8 @@ class CustomerServiceAgent: return any(k in text for k in finish_keywords) def _build_collect_ack(self, count: int) -> str: + if count <= 1: + return "收到这张图了,你还有图就继续发;发完我再一起给你报价。" templates = [ "收到,这边先记下了(已收{n}张)。你继续发,等你发完我再一起给你打包报价。", "好的,当前这批先收到了(第{n}张)。还有图就继续发,发齐我一次性给你总价。", @@ -2027,6 +2029,8 @@ class CustomerServiceAgent: return random.choice(templates).format(n=count) def _build_collect_remind(self, count: int) -> str: + if count <= 1: + return "需求我记下了。你如果还有图继续发,发完回我“发完了”,我给你报价。" templates = [ "需求我记下了(当前共{n}张图)。你继续发齐,发完回我“发完了”,我一次性给你总价。", "好的,这条需求也加上了(现在{n}张)。等你说发完,我立刻统一报价。", @@ -2103,6 +2107,15 @@ class CustomerServiceAgent: single_total = round((total_suggest + extra) / 5) * 5 req_hit = "、".join(req_fee.get("hits", [])) if req_fee.get("hits") else "" + # 单图时不要使用“分图/这批/A-B方案”措辞,避免客户误解为多图。 + if len(results) == 1: + line = detail_lines[0].replace("图1:", "这张:") + lines = [f"给你报下这张:{line.split(':', 1)[1]}"] + if req_hit: + lines.append(f"按你的需求另加{extra}元({req_hit})。") + lines.append(f"这张做下来共{single_total}元,可以的话我马上安排。") + return "\n".join(lines) + lines = ["先给你分图报下:"] lines.extend(detail_lines) if req_hit: diff --git a/tests/test_batch_quote_reply_format.py b/tests/test_batch_quote_reply_format.py index 421755f..d5cccf2 100644 --- a/tests/test_batch_quote_reply_format.py +++ b/tests/test_batch_quote_reply_format.py @@ -61,6 +61,29 @@ class BatchQuoteReplyFormatTest(unittest.IsolatedAsyncioTestCase): self.assertIn("打包", reply) self.assertIn("共", reply) + async def test_single_image_reply_avoids_batch_wording(self): + agent = CustomerServiceAgent() + results = [ + ( + "https://img.alicdn.com/a.jpg", + { + "complexity": "normal", + "reason": "常规处理", + "price_suggest": 20, + }, + ) + ] + reply = agent._build_batch_quote_reply( + results=results, + total_suggest=20, + bundle_price=20, + req_fee={"extra": 0, "hits": []}, + ) + self.assertIn("这张", reply) + self.assertNotIn("这批", reply) + self.assertNotIn("先给你分图报下", reply) + self.assertNotIn("可选:A", reply) + if __name__ == "__main__": unittest.main(verbosity=2)