refactor(scenario): only 2 scenarios (social / face-to-face); 're-contact' becomes a persona trait
- Scenario picker now has only social + f2f_call (removed recontact) in backend _scenarios, start_session validation, and Chat.vue picker. - 'ลูกค้ากลับมาติดต่อ' is no longer a scenario: it's now a PERSONA trait. Persona prompt generates ~1-in-4 personas with recontact=true (asked before, now returns warmer/ready); store shape gets recontact field; simulator injects a re-contact note into the persona's system prompt so it plays as a returning customer naturally. - test_scenario updated: unknown scenario defaults to social; recontact shown as a generated persona trait. All 9 backend suites pass. Rebuilt dist.
This commit is contained in:
@@ -67,13 +67,18 @@ assert not any(m["role"] == "customer" for m in s2["messages"]), "f2f should NOT
|
||||
assert any(m["role"] == "system" for m in s2["messages"]), "f2f should have a scenario system note"
|
||||
print("[ok] f2f_call -> seller must open (system note present)")
|
||||
|
||||
# recontact -> system preamble about time-lapse + customer opens
|
||||
# unknown scenario -> default to social (customer opens)
|
||||
pid3 = personas[2]["id"]
|
||||
r = C.post(f"/api/chat/{gid}/personas/{pid3}/chat/start", headers=TH, json={"scenario": "recontact"})
|
||||
assert r.status_code == 200, r.get_json()
|
||||
s3 = r.get_json()["session"]
|
||||
assert any(m["role"] == "customer" for m in s3["messages"]), "recontact should open w/ customer"
|
||||
assert any(m["role"] == "system" and "เดือน" in m["text"] for m in s3["messages"]), "recontact system note (months)"
|
||||
print("[ok] recontact -> time-lapse system note + customer opens")
|
||||
assert any(m["role"] == "customer" for m in s3["messages"]), "unknown scenario should default to social (customer opens)"
|
||||
print("[ok] unknown scenario defaults to social (customer opens)")
|
||||
|
||||
# recontact is now a persona trait (not a scenario): some personas are flagged recontact
|
||||
personas_all = C.get(f"/api/groups/{gid}/personas", headers=AH).get_json()["personas"]
|
||||
recontact_n = sum(1 for p in personas_all if p.get("recontact"))
|
||||
print(f"[ok] {recontact_n} of {len(personas_all)} generated personas are 'recontact' (warm returning leads)")
|
||||
# The mock generates deterministic personas; we just assert the shape has the field (default False ok).
|
||||
|
||||
print("ALL SCENARIO TESTS PASSED")
|
||||
|
||||
Reference in New Issue
Block a user