import uuid SESSIONS = {} def create_session(query: str) -> str: sid = uuid.uuid4().hex SESSIONS[sid] = { "original_query": query, "round": 0, "history_candidates": [], "user_feedback": [] } return sid def get_session(sid: str): return SESSIONS.get(sid) def update_session_add_candidates(sid: str, candidates: list): s = SESSIONS[sid] s["round"] += 1 s["history_candidates"].extend(candidates) def log_user_choice(sid: str, choice: str): SESSIONS[sid]["user_feedback"].append( {"round": SESSIONS[sid]["round"], "choice": choice} )