From 07e80be9526e8d41fa1d54f6aa350cba31e26bab Mon Sep 17 00:00:00 2001 From: Macky Date: Wed, 19 Aug 2026 09:26:19 +0700 Subject: [PATCH] =?UTF-8?q?fix(persona):=20natural=20Thai=20openers=20-=20?= =?UTF-8?q?'=E0=B8=AA=E0=B8=A7=E0=B8=B1=E0=B8=AA=E0=B8=94=E0=B8=B5?= =?UTF-8?q?=E0=B8=84=E0=B8=A3=E0=B8=B1=E0=B8=9A/=E0=B8=84=E0=B9=88?= =?UTF-8?q?=E0=B8=B0'=20+=20direct=20question,=20no=20'=E0=B9=80=E0=B8=AE?= =?UTF-8?q?=E0=B9=89/=E0=B9=80=E0=B8=AD=E0=B9=89'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - persona_prompts OPENER RULE: mandate polite Thai openers that start with สวัสดีครับ/ค่ะ and go straight to the question or 'สนใจ/สอบถาม'; explicitly forbid casual English fillers (เฮ้/เอ้/เอ่อ/hey) and singsong slang for Thai - chat_routes: default opener fallback is now locale-aware - Thai locale uses 'สวัสดีครับ สนใจสินค้าของคุณครับ...' instead of the English one --- backend/app/api/chat_routes.py | 4 ++-- backend/app/services/persona_prompts.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/backend/app/api/chat_routes.py b/backend/app/api/chat_routes.py index 018a679..d3ff8ac 100644 --- a/backend/app/api/chat_routes.py +++ b/backend/app/api/chat_routes.py @@ -327,7 +327,7 @@ def start_session(gid: str, pid: str): if scenario_meta.get("preamble"): seeded.append({"role": "system", "text": scenario_meta["preamble"]}) if init_mode == "customer": - opener = persona.get("opener") or "Hi, I saw your product and had a question." + opener = persona.get("opener") or (("สวัสดีครับ สนใจสินค้าของคุณครับ ขอถามรายละเอียดหน่อยได้ไหม" if locale == "th" else "Hi, I saw your product and had a question.")) seeded.append({"role": "customer", "text": opener}) initial_internal = {"turns": 0, "score": 50, "signals": []} @@ -348,7 +348,7 @@ def start_session(gid: str, pid: str): if scenario_meta.get("preamble"): seeded.append({"role": "system", "text": scenario_meta["preamble"]}) if init_mode == "customer": - opener = persona.get("opener") or "Hi, I saw your product and had a question." + opener = persona.get("opener") or (("สวัสดีครับ สนใจสินค้าของคุณครับ ขอถามรายละเอียดหน่อยได้ไหม" if locale == "th" else "Hi, I saw your product and had a question.")) seeded.append({"role": "customer", "text": opener}) session, resumed = s["sessions"].start( org_id=org_id, diff --git a/backend/app/services/persona_prompts.py b/backend/app/services/persona_prompts.py index 5a78678..09c4eb2 100644 --- a/backend/app/services/persona_prompts.py +++ b/backend/app/services/persona_prompts.py @@ -50,11 +50,14 @@ RULES: 7. difficulty 1-5. special="" unless wrong_text. 8. OPENER RULE (IMPORTANT): the `opener` is what the customer says FIRST when initiation_mode="customer". Every opener — for EVERY tier, including wrong_text and every tier-C persona — must be a natural, polite, - in-character customer greeting that starts warmly or neutrally and expresses some interest or a question - (e.g. "สวัสดีค่ะ เห็นสินค้าคุณแล้ว สนใจอยากสอบถาม" / "สวัสดีครับ เข้าไปดูเพจมา อยากถามราคาหน่อย" / "Hi, I saw - your page and had a question"). NEVER make the opener a complaint, a refusal, a price grumble, a "never - mind", or anything negative — the customer's resistance must only surface DURING the conversation, not - in their very first message. + in-character customer greeting that starts warmly or neutrally and expresses some interest or a question. + EXAMPLES (Thai): "สวัสดีครับ สนใจสินค้าตัวนี้ ขอถามราคาหน่อยได้ไหม" / "สวัสดีค่ะ เห็นโฆษณาแฟนเพจมา เลยอยากสอบถาม" / "สวัสดีครับ ซื้อของที่นี่แล้วสั่ง-จัดส่งยังไงบ้าง" / "สนใจสินค้าในแฟนเพจครับ สอบถามรายละเอียดได้ไหม". + THAI STYLE (MANDATORY): Start with "สวัสดีครับ/ค่ะ" then go straight to the question or the word "สนใจ/สอบถาม" — + do NOT open with casual English-style interjections or filler like "เฮ้", "เอ้", "เอ่อ", "hey", "hi ya", or + singsong slang ("ไง", "นี่ๆ", "ว่าไง"). A question that gets to the point directly is ideal. For English, + a plain "Hi" or "Hello" is fine. + NEVER make the opener a complaint, a refusal, a price grumble, a "never mind", or anything negative — the + customer's resistance must only surface DURING the conversation, not in their very first message. 9. Language: output all human text in the requested language. Only output valid JSON: {"personas": [ ... ]} """