mtyrrell commited on
Commit
197d3e1
·
1 Parent(s): 33d86e0
Files changed (1) hide show
  1. auditqa/utils.py +7 -1
auditqa/utils.py CHANGED
@@ -32,15 +32,21 @@ logger.setLevel(logging.DEBUG) # Ensure debug logging is enabled
32
  # print("logging done")
33
 
34
 
 
 
 
35
  def save_logs(JSON_DATASET_PATH: str, logs: dict, feedback: str = None) -> None:
36
  """ Every interaction with app saves the log of question and answer,
37
  this is to get the usage statistics of app and evaluate model performances.
38
  Also saves user feedback (when provided).
39
  """
40
  try:
 
 
 
41
  if feedback:
42
  logs["feedback"] = feedback
43
- logging.debug(f"Adding feedback to logs: {feedback}")
44
 
45
  with open(JSON_DATASET_PATH, 'a') as f:
46
  json.dump(logs, f)
 
32
  # print("logging done")
33
 
34
 
35
+ import os
36
+ from pathlib import Path
37
+
38
  def save_logs(JSON_DATASET_PATH: str, logs: dict, feedback: str = None) -> None:
39
  """ Every interaction with app saves the log of question and answer,
40
  this is to get the usage statistics of app and evaluate model performances.
41
  Also saves user feedback (when provided).
42
  """
43
  try:
44
+ # Create directory if it doesn't exist
45
+ os.makedirs(os.path.dirname(JSON_DATASET_PATH), exist_ok=True)
46
+
47
  if feedback:
48
  logs["feedback"] = feedback
49
+ logger.debug(f"Adding feedback to logs: {feedback}")
50
 
51
  with open(JSON_DATASET_PATH, 'a') as f:
52
  json.dump(logs, f)