Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,23 @@ def output_guard(answer):
|
|
21 |
return False
|
22 |
# You can add more checks here if needed
|
23 |
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
|
26 |
import re
|
@@ -162,18 +179,7 @@ class MathRouter(dspy.Program):
|
|
162 |
|
163 |
router = MathRouter()
|
164 |
|
165 |
-
|
166 |
-
def store_feedback(question, answer, feedback, correct_answer):
|
167 |
-
entry = {
|
168 |
-
"question": question,
|
169 |
-
"model_answer": answer,
|
170 |
-
"feedback": feedback,
|
171 |
-
"correct_answer": correct_answer,
|
172 |
-
"timestamp": str(datetime.now())
|
173 |
-
}
|
174 |
-
print("Storing feedback:", entry)
|
175 |
-
with open("feedback.json", "a") as f:
|
176 |
-
f.write(json.dumps(entry) + "\n")
|
177 |
|
178 |
# === Gradio Functions ===
|
179 |
def ask_question(question):
|
|
|
21 |
return False
|
22 |
# You can add more checks here if needed
|
23 |
return True
|
24 |
+
import os
|
25 |
+
from datetime import datetime
|
26 |
+
|
27 |
+
# Safe path for Hugging Face Spaces (will reset on restart)
|
28 |
+
feedback_path = "/tmp/feedback.json"
|
29 |
+
|
30 |
+
def store_feedback(question, answer, feedback, correct_answer):
|
31 |
+
entry = {
|
32 |
+
"question": question,
|
33 |
+
"model_answer": answer,
|
34 |
+
"feedback": feedback,
|
35 |
+
"correct_answer": correct_answer,
|
36 |
+
"timestamp": str(datetime.now())
|
37 |
+
}
|
38 |
+
print("Storing feedback:", entry)
|
39 |
+
with open(feedback_path, "a") as f:
|
40 |
+
f.write(json.dumps(entry) + "\n")
|
41 |
|
42 |
|
43 |
import re
|
|
|
179 |
|
180 |
router = MathRouter()
|
181 |
|
182 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
# === Gradio Functions ===
|
185 |
def ask_question(question):
|