IAMTFRMZA commited on
Commit
8d4e339
·
verified ·
1 Parent(s): f059f48
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -49,6 +49,14 @@ tab1, tab2 = st.tabs(["Contract", "Technical"])
49
 
50
  FLAGGED_RESPONSES_FILE = "/mnt/data/flagged_responses.json"
51
 
 
 
 
 
 
 
 
 
52
  def save_flagged_response(user_query, ai_response):
53
  flagged_data = {
54
  "query": user_query,
@@ -56,14 +64,11 @@ def save_flagged_response(user_query, ai_response):
56
  "timestamp": datetime.now().isoformat()
57
  }
58
 
59
- if os.path.exists(FLAGGED_RESPONSES_FILE):
60
- with open(FLAGGED_RESPONSES_FILE, "r") as file:
61
- try:
62
- existing_data = json.load(file)
63
- except json.JSONDecodeError:
64
- existing_data = []
65
- else:
66
- existing_data = []
67
 
68
  existing_data.append(flagged_data)
69
 
 
49
 
50
  FLAGGED_RESPONSES_FILE = "/mnt/data/flagged_responses.json"
51
 
52
+ # Ensure the flagged responses file exists
53
+ def ensure_flagged_file():
54
+ if not os.path.exists(FLAGGED_RESPONSES_FILE):
55
+ with open(FLAGGED_RESPONSES_FILE, "w") as file:
56
+ json.dump([], file) # Initialize with an empty list
57
+
58
+ ensure_flagged_file()
59
+
60
  def save_flagged_response(user_query, ai_response):
61
  flagged_data = {
62
  "query": user_query,
 
64
  "timestamp": datetime.now().isoformat()
65
  }
66
 
67
+ with open(FLAGGED_RESPONSES_FILE, "r") as file:
68
+ try:
69
+ existing_data = json.load(file)
70
+ except json.JSONDecodeError:
71
+ existing_data = []
 
 
 
72
 
73
  existing_data.append(flagged_data)
74