File size: 740 Bytes
71d0d94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import json
import time


def save_feedback(cache_dir: str, feedback_type: str, comment: str = None):
    print(f"==> Saving feedback to {cache_dir}")
    print(f"==> Feedback type: {feedback_type}")
    print(f"==> Comment: {comment}")

    feedback_file = os.path.join(cache_dir, "user_feedback.json")
    if os.path.exists(feedback_file):
        with open(feedback_file, 'r') as f:
            feedback_data = json.load(f)
    else:
        feedback_data = []
    
    feedback_data.append({
        "timestamp": time.strftime("%Y%m%d_%H%M%S"),
        "feedback_type": feedback_type,
        "comment": comment
    })

    # Save feedback
    with open(feedback_file, 'w') as f:
        json.dump(feedback_data, f, indent=4)