Spaces:
Sleeping
Sleeping
Update logger.py
Browse files
logger.py
CHANGED
@@ -1,26 +1,48 @@
|
|
1 |
import csv
|
2 |
import os
|
|
|
3 |
|
4 |
LOG_FILE = "feedback_log.csv"
|
5 |
|
6 |
-
def log_feedback(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
file_exists = os.path.isfile(LOG_FILE)
|
|
|
8 |
with open(LOG_FILE, mode='a', newline='', encoding='utf-8') as file:
|
9 |
writer = csv.writer(file)
|
|
|
10 |
if not file_exists:
|
11 |
writer.writerow([
|
|
|
12 |
"question",
|
13 |
"option1",
|
14 |
"option2",
|
15 |
"context",
|
16 |
"evo_output",
|
17 |
-
"
|
|
|
|
|
18 |
])
|
|
|
19 |
writer.writerow([
|
|
|
20 |
question,
|
21 |
option1,
|
22 |
option2,
|
23 |
context,
|
24 |
evo_output,
|
25 |
-
|
|
|
|
|
26 |
])
|
|
|
1 |
import csv
|
2 |
import os
|
3 |
+
from datetime import datetime
|
4 |
|
5 |
LOG_FILE = "feedback_log.csv"
|
6 |
|
7 |
+
def log_feedback(
|
8 |
+
question,
|
9 |
+
option1,
|
10 |
+
option2,
|
11 |
+
context,
|
12 |
+
evo_output,
|
13 |
+
gpt_output,
|
14 |
+
evo_reasoning,
|
15 |
+
user_preference=None
|
16 |
+
):
|
17 |
+
"""
|
18 |
+
Logs Evo and GPT output for learning.
|
19 |
+
"""
|
20 |
file_exists = os.path.isfile(LOG_FILE)
|
21 |
+
|
22 |
with open(LOG_FILE, mode='a', newline='', encoding='utf-8') as file:
|
23 |
writer = csv.writer(file)
|
24 |
+
|
25 |
if not file_exists:
|
26 |
writer.writerow([
|
27 |
+
"timestamp",
|
28 |
"question",
|
29 |
"option1",
|
30 |
"option2",
|
31 |
"context",
|
32 |
"evo_output",
|
33 |
+
"gpt_output",
|
34 |
+
"evo_reasoning",
|
35 |
+
"user_preference"
|
36 |
])
|
37 |
+
|
38 |
writer.writerow([
|
39 |
+
datetime.now().isoformat(),
|
40 |
question,
|
41 |
option1,
|
42 |
option2,
|
43 |
context,
|
44 |
evo_output,
|
45 |
+
gpt_output,
|
46 |
+
evo_reasoning,
|
47 |
+
user_preference or ""
|
48 |
])
|