import json import os def log_interaction(question, response, params): """Log interaction details to a JSON file.""" log_entry = { "question": question, "response": response, "params": params } log_file_path = "interaction_log.json" logs = [] if os.path.exists(log_file_path): with open(log_file_path, "r") as log_file: logs = json.load(log_file) logs.append(log_entry) with open(log_file_path, "w") as log_file: json.dump(logs, log_file, indent=4)