from collections import defaultdict # In-memory chat storage chat_histories = defaultdict(list) def get_history_for_user(user_id: str): return chat_histories[user_id] def store_interaction(user_id: str, user_msg: str, assistant_msg: str): chat_histories[user_id].append({ "user": user_msg, "assistant": assistant_msg })