Spaces:
Sleeping
Sleeping
elibrowne
commited on
Commit
·
df99dda
1
Parent(s):
d503b50
Persistence?
Browse files
app.py
CHANGED
|
@@ -100,16 +100,14 @@ def reset_current_response():
|
|
| 100 |
with open("question_data.json", "r") as f:
|
| 101 |
all_questions = json.load(f)
|
| 102 |
|
| 103 |
-
def test_info():
|
| 104 |
-
gr.Info("test")
|
| 105 |
-
|
| 106 |
# Loads the user's current question — this is the first question that the user has not made any progress on.
|
| 107 |
def load_current_question():
|
| 108 |
global current_question
|
| 109 |
q_index = user_data["current"]
|
| 110 |
if q_index >= len(all_questions):
|
| 111 |
print("Done")
|
| 112 |
-
gr.Info("You've finished — thank you so much!")
|
|
|
|
| 113 |
else:
|
| 114 |
qid = user_data["order"][q_index]
|
| 115 |
current_question = all_questions[qid]
|
|
@@ -269,9 +267,9 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 269 |
eval_satisfied: gr.Slider(value = 1)
|
| 270 |
}
|
| 271 |
else:
|
| 272 |
-
print(user_data["current"])
|
| 273 |
user_data["current"] += 1
|
| 274 |
-
|
|
|
|
| 275 |
load_current_question()
|
| 276 |
return {
|
| 277 |
selection: gr.Markdown("Advancing to the next question..."),
|
|
@@ -292,6 +290,7 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 292 |
}
|
| 293 |
# When mode is 1 -> change question
|
| 294 |
user_data["current"] += 1
|
|
|
|
| 295 |
load_current_question()
|
| 296 |
return {
|
| 297 |
selection: gr.Markdown("Advancing to the next question..."),
|
|
@@ -327,7 +326,6 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 327 |
global step
|
| 328 |
global mode
|
| 329 |
step = 0
|
| 330 |
-
test_info()
|
| 331 |
if mode == 0:
|
| 332 |
mode = 1 # update mode to 1, will restart with same Q, next set of Ps
|
| 333 |
print("Next set of passages for same question")
|
|
|
|
| 100 |
with open("question_data.json", "r") as f:
|
| 101 |
all_questions = json.load(f)
|
| 102 |
|
|
|
|
|
|
|
|
|
|
| 103 |
# Loads the user's current question — this is the first question that the user has not made any progress on.
|
| 104 |
def load_current_question():
|
| 105 |
global current_question
|
| 106 |
q_index = user_data["current"]
|
| 107 |
if q_index >= len(all_questions):
|
| 108 |
print("Done")
|
| 109 |
+
gr.Info("You've finished — thank you so much! There are no more questions. :)")
|
| 110 |
+
current_question = {"question": "You're done! Thanks so much for your help.", "answers": ["I want to log out now.", "I want to keep answering questions.","I want to keep answering questions.", "I want to keep answering questions."], "correct_answer_index": 0, "top10_e5": ["You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!"], "generation_e5": "I don't know how to exit this code right now, so you're in an endless loop of this question until you quit.", "top10_colbert": ["You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!", "You're done; thank you!"], "generation_colbert": "I don't know how to exit this code right now, so you're in an endless loop of this question until you quit.", "top10_contains_gold_passage": False, "gold_passage": "GOLD PASSAGE: LOG OFF!", "gold_passage_generation": "what do you gain"}
|
| 111 |
else:
|
| 112 |
qid = user_data["order"][q_index]
|
| 113 |
current_question = all_questions[qid]
|
|
|
|
| 267 |
eval_satisfied: gr.Slider(value = 1)
|
| 268 |
}
|
| 269 |
else:
|
|
|
|
| 270 |
user_data["current"] += 1
|
| 271 |
+
# TODO save answers x2
|
| 272 |
+
update_huggingface(user_id) # persistence — update progress online, save answers
|
| 273 |
load_current_question()
|
| 274 |
return {
|
| 275 |
selection: gr.Markdown("Advancing to the next question..."),
|
|
|
|
| 290 |
}
|
| 291 |
# When mode is 1 -> change question
|
| 292 |
user_data["current"] += 1
|
| 293 |
+
update_huggingface(user_id)
|
| 294 |
load_current_question()
|
| 295 |
return {
|
| 296 |
selection: gr.Markdown("Advancing to the next question..."),
|
|
|
|
| 326 |
global step
|
| 327 |
global mode
|
| 328 |
step = 0
|
|
|
|
| 329 |
if mode == 0:
|
| 330 |
mode = 1 # update mode to 1, will restart with same Q, next set of Ps
|
| 331 |
print("Next set of passages for same question")
|