Spaces:
Runtime error
Runtime error
logs
Browse files- 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 |
-
|
36 |
-
|
|
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
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':
|