mtyrrell commited on
Commit
15565f4
·
1 Parent(s): 2c3e899
Files changed (1) hide show
  1. auditqa/utils.py +28 -11
auditqa/utils.py CHANGED
@@ -12,19 +12,36 @@ from uuid import uuid4
12
 
13
 
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  def save_logs(scheduler, JSON_DATASET_PATH, logs, feedback=None) -> None:
16
- """ Every interaction with app saves the log of question and answer,
17
- this is to get the usage statistics of app and evaluate model performances.
18
- Also saves user feedback (when provided).
19
- """
20
- if feedback:
21
- logs["feedback"] = feedback #optional
22
 
23
- with scheduler.lock:
24
- with JSON_DATASET_PATH.open("a") as f:
25
- json.dump(logs, f)
26
- f.write("\n")
27
- print("logging done")
 
 
 
 
 
 
28
 
29
  def get_message_template(type, SYSTEM_PROMPT, USER_PROMPT):
30
  if type == 'NVIDIA':
 
12
 
13
 
14
 
15
+ # def save_logs(scheduler, JSON_DATASET_PATH, logs, feedback=None) -> None:
16
+ # """ Every interaction with app saves the log of question and answer,
17
+ # this is to get the usage statistics of app and evaluate model performances.
18
+ # Also saves user feedback (when provided).
19
+ # """
20
+ # if feedback:
21
+ # logs["feedback"] = feedback #optional
22
+
23
+ # with scheduler.lock:
24
+ # with JSON_DATASET_PATH.open("a") as f:
25
+ # json.dump(logs, f)
26
+ # f.write("\n")
27
+ # print("logging done")
28
+
29
  def save_logs(scheduler, JSON_DATASET_PATH, logs, feedback=None) -> None:
30
+ try:
31
+ # Create directory if it doesn't exist
32
+ JSON_DATASET_PATH.parent.mkdir(parents=True, exist_ok=True)
 
 
 
33
 
34
+ # Your existing code
35
+ if feedback:
36
+ logs["feedback"] = feedback
37
+
38
+ with scheduler.lock:
39
+ with JSON_DATASET_PATH.open("a") as f:
40
+ json.dump(logs, f)
41
+ f.write("\n")
42
+ print("logging done")
43
+ except Exception as e:
44
+ print(f"Error saving logs: {str(e)}") # Add error logging
45
 
46
  def get_message_template(type, SYSTEM_PROMPT, USER_PROMPT):
47
  if type == 'NVIDIA':