HemanM commited on
Commit
8e0fcfe
·
verified ·
1 Parent(s): c6a03b9

Update logger.py

Browse files
Files changed (1) hide show
  1. logger.py +10 -7
logger.py CHANGED
@@ -1,8 +1,15 @@
1
- import csv
 
2
  from datetime import datetime
3
 
 
 
 
 
 
 
4
  def log_interaction(goal, sol1, sol2, evo, gpt, correct=None, source="user"):
5
- row = {
6
  "timestamp": datetime.utcnow().isoformat(),
7
  "goal": goal,
8
  "solution_1": sol1,
@@ -13,8 +20,4 @@ def log_interaction(goal, sol1, sol2, evo, gpt, correct=None, source="user"):
13
  "source": source
14
  }
15
 
16
- with open("evo_feedback_log.csv", mode="a", newline="") as file:
17
- writer = csv.DictWriter(file, fieldnames=row.keys())
18
- if file.tell() == 0:
19
- writer.writeheader()
20
- writer.writerow(row)
 
1
+ import firebase_admin
2
+ from firebase_admin import credentials, firestore
3
  from datetime import datetime
4
 
5
+ # Load credentials (ensure this JSON is uploaded as a private file on Hugging Face or locally)
6
+ cred = credentials.Certificate("firebase_key.json") # Keep this secure
7
+ firebase_admin.initialize_app(cred)
8
+
9
+ db = firestore.client()
10
+
11
  def log_interaction(goal, sol1, sol2, evo, gpt, correct=None, source="user"):
12
+ doc = {
13
  "timestamp": datetime.utcnow().isoformat(),
14
  "goal": goal,
15
  "solution_1": sol1,
 
20
  "source": source
21
  }
22
 
23
+ db.collection("evo_logs").add(doc)