mtyrrell commited on
Commit
5981899
·
1 Parent(s): 8aba5e3
Files changed (1) hide show
  1. auditqa/utils.py +11 -6
auditqa/utils.py CHANGED
@@ -32,13 +32,18 @@ def save_logs(JSON_DATASET_PATH: str, logs: dict, feedback: str = None) -> None:
32
  this is to get the usage statistics of app and evaluate model performances.
33
  Also saves user feedback (when provided).
34
  """
35
- if feedback:
36
- logs["feedback"] = feedback
 
 
37
 
38
- with open(JSON_DATASET_PATH, 'a') as f:
39
- json.dump(logs, f)
40
- f.write("\n")
41
- print("logging done")
 
 
 
42
 
43
  def get_message_template(type, SYSTEM_PROMPT, USER_PROMPT):
44
  if type == 'NVIDIA':
 
32
  this is to get the usage statistics of app and evaluate model performances.
33
  Also saves user feedback (when provided).
34
  """
35
+ try:
36
+ if feedback:
37
+ logs["feedback"] = feedback
38
+ logging.debug(f"Adding feedback to logs: {feedback}")
39
 
40
+ with open(JSON_DATASET_PATH, 'a') as f:
41
+ json.dump(logs, f)
42
+ f.write("\n")
43
+ logging.info(f"Successfully saved logs to {JSON_DATASET_PATH}")
44
+ except Exception as e:
45
+ logging.error(f"Failed to save logs to {JSON_DATASET_PATH}: {str(e)}")
46
+ raise
47
 
48
  def get_message_template(type, SYSTEM_PROMPT, USER_PROMPT):
49
  if type == 'NVIDIA':