File size: 568 Bytes
ceabc0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)