feat(chat): persona decides to buy/walk — auto-finish + tolerance (temper) + resume
The conversation now ENDS when the persona makes a decision (option C), not when the
trainee clicks a button:
- persona_id replies carry {reply, decision(none/buy/walk), mood}; when decision is
buy/walk the session auto-finishes (won/lost) with a debrief that reveals latent
details + per-turn 'turning points'.
- personas have a tolerance (1-5, 'temper'): impatient personas walk away fast after
poor answers (fed via internal.misses on mood<=-1); tough 'wrong text' cases can
still be won by a strong, gentle response (judge realism).
- trainee 'Finish' button removed; if they leave mid-chat an active session is resumed
via /chat/resume (continue, not restart). One-shot lock still enforced once decided.
- mock/tests updated: persona deciding buy -> send auto-finishes won.
Rebuilt dist.
This commit is contained in:
@@ -87,16 +87,15 @@ def main():
|
||||
r = client.post(f"/api/chat/{gid}/personas/{pid}/chat/send",
|
||||
json={"text": "Hi, I run a small noodle shop. Tell me about pricing."}, headers=UH)
|
||||
assert r.status_code == 200, r.get_json()
|
||||
assert r.get_json()["reply"]
|
||||
print("[ok] send message -> persona replies")
|
||||
|
||||
# finish -> debrief reveals latent + outcome won
|
||||
r = client.post(f"/api/chat/{gid}/personas/{pid}/chat/finish", headers=UH)
|
||||
assert r.status_code == 200, r.get_json()
|
||||
debrief = r.get_json()["debrief"]
|
||||
assert debrief["outcome"] == "won"
|
||||
body = r.get_json()
|
||||
assert body["reply"]
|
||||
# Mock persona decides to buy on this send -> session auto-finishes as won.
|
||||
assert body.get("finished") is True, body
|
||||
assert body.get("outcome") == "won", body
|
||||
debrief = body.get("debrief") or {}
|
||||
assert debrief.get("outcome") == "won"
|
||||
assert "revealed_persona" in debrief and "pains" in debrief["revealed_persona"]
|
||||
print("[ok] finish -> debrief with latent reveal + outcome")
|
||||
print("[ok] send -> persona decides (buy) -> session auto-finishes won with debrief")
|
||||
|
||||
# ONE-SHOT: cannot start again on same persona
|
||||
r = client.post(f"/api/chat/{gid}/personas/{pid}/chat/start", headers=UH)
|
||||
|
||||
Reference in New Issue
Block a user