# -*- coding: utf-8 -*- from quiz_data import PROFILES def start_state(): return { "phase": "quiz", "current_question_index": 0, "answers": [], "profile_counts": { "explorer": 0, "builder": 0, "orchestrator": 0, "leader": 0, }, "first_name": "", "last_name": "", "email": "", "company": "", "job_title": "", "final_profile_key": None, "finished": False, } def compute_winning_profile(profile_counts): # Poids pour gérer l'égalité (le plus mature l'emporte) maturity_weight = { "leader": 4, "orchestrator": 3, "builder": 2, "explorer": 1 } max_score = max(profile_counts.values()) candidates = [p for p, score in profile_counts.items() if score == max_score] # Tie-breaker : prend le candidat avec le poids le plus élevé winning_profile = max(candidates, key=lambda p: maturity_weight[p]) return winning_profile def build_profile_summary_prompt(profile_key, answers): profile = PROFILES[profile_key] answers_text = "\n".join([f"- {a['question']} : {a['answer']}" for a in answers]) prompt = f""" Based on the following answers from a CX maturity quiz, write a short, encouraging 2-sentence summary. The user's assigned profile is: {profile['label']}. User's Answers: {answers_text} Write the response directly to the user (e.g. "Your answers show that..."). Keep it very brief, professional, and aligned with Merkle's expertise in Customer Experience. """ return prompt