File size: 734 Bytes
4af310b 5bf211e 4e0f514 4af310b 4e0f514 4af310b 5bf211e 4e0f514 4af310b |
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 |
import json
from time import time
LOG_FILE = "rag_eval_logs.jsonl"
def log_eval(
query: str,
retrieved_count: int,
confidence: float,
answer_known: bool,
source_type: str = "internal_pdf",
final_answer: str = "",
context_list: list = None
):
if context_list is None:
context_list = []
record = {
"timestamp": time(),
"query": query,
"retrieved_count": retrieved_count,
"confidence": confidence,
"answer_known": answer_known,
"source_type": source_type,
"final_answer": final_answer,
"context_list": context_list
}
with open(LOG_FILE, "a", encoding="utf-8") as f:
f.write(json.dumps(record) + "\n")
|