File size: 1,279 Bytes
80cdad4
 
c1de334
80cdad4
 
 
c1de334
 
 
 
 
 
 
 
 
 
 
d45f9ca
c1de334
80cdad4
d45f9ca
80cdad4
 
c1de334
80cdad4
bcf74f5
c1de334
bcf74f5
 
 
 
 
c1de334
 
d45f9ca
 
bcf74f5
d45f9ca
 
 
 
 
bcf74f5
c1de334
bcf74f5
 
 
 
 
c1de334
 
d45f9ca
 
bcf74f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import csv
import os
from datetime import datetime

LOG_FILE = "feedback_log.csv"

def log_feedback(
    question,
    option1,
    option2,
    context,
    evo_output,
    gpt_output,
    evo_reasoning,
    user_preference=None
):
    """
    Logs Evo and GPT output along with user's preference for retraining.
    """
    file_exists = os.path.isfile(LOG_FILE)

    with open(LOG_FILE, mode='a', newline='', encoding='utf-8') as file:
        writer = csv.writer(file)

        if not file_exists:
            writer.writerow([
                "timestamp",
                "question",
                "option1",
                "option2",
                "context",
                "evo_output",
                "gpt_output",
                "evo_reasoning",
                "user_preference",
                "evo_was_correct"
            ])

        evo_was_correct = "yes" if user_preference == "Evo" else (
            "no" if user_preference == "GPT" else ""
        )

        writer.writerow([
            datetime.now().isoformat(),
            question,
            option1,
            option2,
            context,
            evo_output,
            gpt_output,
            evo_reasoning,
            user_preference or "",
            evo_was_correct
        ])