Spaces:
Running
Running
import firebase_admin | |
from firebase_admin import credentials, firestore | |
from datetime import datetime | |
# Load credentials (ensure this JSON is uploaded as a private file on Hugging Face or locally) | |
cred = credentials.Certificate("firebase_key.json") # Keep this secure | |
firebase_admin.initialize_app(cred) | |
db = firestore.client() | |
def log_interaction(goal, sol1, sol2, evo, gpt, correct=None, source="user"): | |
doc = { | |
"timestamp": datetime.utcnow().isoformat(), | |
"goal": goal, | |
"solution_1": sol1, | |
"solution_2": sol2, | |
"evo_answer": evo, | |
"gpt_answer": gpt, | |
"correct_answer": correct if correct else gpt, | |
"source": source | |
} | |
db.collection("evo_logs").add(doc) | |