Spaces:
Sleeping
Sleeping
elibrowne
commited on
Commit
·
8e8e412
1
Parent(s):
a31c72c
State?
Browse files
app.py
CHANGED
|
@@ -446,8 +446,8 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 446 |
c.click(fn = answer_c, inputs = [current_response], outputs = [question, evals, current_response])
|
| 447 |
d.click(fn = answer_d, inputs = [current_response], outputs = [question, evals, current_response])
|
| 448 |
|
| 449 |
-
def toggle(step, mode):
|
| 450 |
-
step = 0
|
| 451 |
if mode == 0: # temporarily disabled — will never be mode 0
|
| 452 |
mode = 1 # update mode to 1, will restart with same Q, next set of Ps
|
| 453 |
print("Next set of passages for same question")
|
|
@@ -456,28 +456,28 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 456 |
scores_g: gr.Column(visible = False),
|
| 457 |
evals: gr.Row(visible = True),
|
| 458 |
question: gr.Row(visible = False),
|
| 459 |
-
step: step,
|
| 460 |
-
mode: mode
|
| 461 |
}
|
| 462 |
else:
|
| 463 |
# reset mode to 0, will restart with new Q (set up new Q), first set of Ps
|
| 464 |
# mode = 0 -> RIGHT NOW, ALWAYS 1
|
| 465 |
print("New question")
|
| 466 |
-
new_answers =
|
| 467 |
-
new_answers[
|
| 468 |
return {
|
| 469 |
scores_p: gr.Column(visible = True),
|
| 470 |
scores_g: gr.Column(visible = False),
|
| 471 |
evals: gr.Row(visible = False),
|
| 472 |
question: gr.Row(visible = True),
|
| 473 |
-
q_text: gr.Markdown(
|
| 474 |
-
a: gr.Button(
|
| 475 |
-
b: gr.Button(
|
| 476 |
-
c: gr.Button(
|
| 477 |
-
d: gr.Button(
|
| 478 |
passage_display: gr.Markdown("""
|
| 479 |
## Question and Answer
|
| 480 |
-
*""" +
|
| 481 |
"""* \n
|
| 482 |
+ """ + new_answers[0] +
|
| 483 |
""" \n
|
|
@@ -488,12 +488,12 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 488 |
+ """ + new_answers[3]),
|
| 489 |
selection: gr.HTML("""
|
| 490 |
<h2> Retrieved Passage </h2>
|
| 491 |
-
<p> """ +
|
| 492 |
-
step:
|
| 493 |
-
mode: mode
|
| 494 |
} # note change from "top10_" + user_data["modes"][user_data["current"]][mode]][0]
|
| 495 |
|
| 496 |
-
forward_btn.change(fn = toggle, inputs = [step, mode], outputs = [scores_p, scores_g, evals, question, q_text, a, b, c, d, passage_display, selection, step, mode])
|
| 497 |
|
| 498 |
with gr.Row() as login:
|
| 499 |
with gr.Column():
|
|
|
|
| 446 |
c.click(fn = answer_c, inputs = [current_response], outputs = [question, evals, current_response])
|
| 447 |
d.click(fn = answer_d, inputs = [current_response], outputs = [question, evals, current_response])
|
| 448 |
|
| 449 |
+
def toggle(step, mode, cq):
|
| 450 |
+
# step = 0
|
| 451 |
if mode == 0: # temporarily disabled — will never be mode 0
|
| 452 |
mode = 1 # update mode to 1, will restart with same Q, next set of Ps
|
| 453 |
print("Next set of passages for same question")
|
|
|
|
| 456 |
scores_g: gr.Column(visible = False),
|
| 457 |
evals: gr.Row(visible = True),
|
| 458 |
question: gr.Row(visible = False),
|
| 459 |
+
# step: step,
|
| 460 |
+
# mode: mode
|
| 461 |
}
|
| 462 |
else:
|
| 463 |
# reset mode to 0, will restart with new Q (set up new Q), first set of Ps
|
| 464 |
# mode = 0 -> RIGHT NOW, ALWAYS 1
|
| 465 |
print("New question")
|
| 466 |
+
new_answers = cq["answers"].copy()
|
| 467 |
+
new_answers[cq["correct_answer_index"]] = "**" + cq["answers"][cq["correct_answer_index"]] + "** ✅"
|
| 468 |
return {
|
| 469 |
scores_p: gr.Column(visible = True),
|
| 470 |
scores_g: gr.Column(visible = False),
|
| 471 |
evals: gr.Row(visible = False),
|
| 472 |
question: gr.Row(visible = True),
|
| 473 |
+
q_text: gr.Markdown(cq["question"]),
|
| 474 |
+
a: gr.Button(cq["answers"][0]),
|
| 475 |
+
b: gr.Button(cq["answers"][1]),
|
| 476 |
+
c: gr.Button(cq["answers"][2]),
|
| 477 |
+
d: gr.Button(cq["answers"][3]),
|
| 478 |
passage_display: gr.Markdown("""
|
| 479 |
## Question and Answer
|
| 480 |
+
*""" + cq["question"] +
|
| 481 |
"""* \n
|
| 482 |
+ """ + new_answers[0] +
|
| 483 |
""" \n
|
|
|
|
| 488 |
+ """ + new_answers[3]),
|
| 489 |
selection: gr.HTML("""
|
| 490 |
<h2> Retrieved Passage </h2>
|
| 491 |
+
<p> """ + cq["top10_e5"][0] + "</p>"),
|
| 492 |
+
step: 0,
|
| 493 |
+
# mode: mode
|
| 494 |
} # note change from "top10_" + user_data["modes"][user_data["current"]][mode]][0]
|
| 495 |
|
| 496 |
+
forward_btn.change(fn = toggle, inputs = [step, mode, current_question], outputs = [scores_p, scores_g, evals, question, q_text, a, b, c, d, passage_display, selection, step, mode])
|
| 497 |
|
| 498 |
with gr.Row() as login:
|
| 499 |
with gr.Column():
|