mcamargo00 commited on
Commit
ee2ea54
·
verified ·
1 Parent(s): e48dd4a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -702,6 +702,16 @@ def ui_surprise(selector, filter_label="any"):
702
  if not r:
703
  return selector, gr.update(), gr.update()
704
  return selector, r["question"], r["solution"]
 
 
 
 
 
 
 
 
 
 
705
 
706
  components_to_clear = [
707
  question_input,
@@ -740,7 +750,7 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()) as app:
740
  with gr.Row():
741
  classify_btn = gr.Button("Classify Solution", variant="primary")
742
  surprise_btn = gr.Button("Surprise me")
743
- clear_btn = clear_btn = gr.ClearButton(components=components_to_clear, value="Clear")
744
 
745
  # -------- Right: outputs --------
746
  with gr.Column(scale=1):
@@ -757,7 +767,7 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()) as app:
757
  ["A rectangle's length is twice its width. If the width is 7 cm, what is the perimeter of the rectangle?",
758
  "The length of the rectangle is 2 * 7 = 14 cm.\n The perimeter is 14 + 7 = 21 cm.\n Final answer: 21",
759
  "Conceptually flawed"],
760
- ["",
761
  "The lateral area of the bottom layer is 2 * 3.14 * 20 * 8 = 1004.8.\n The lateral area of the middle layer is 2 * 3.14 * 15 * 8 = 753.6.\n The lateral area of the top layer is 2 * 3.14 * 10 * 8 = 502.4.\n The exposed top surface is the area of the smallest circle: 3.14 * (10*10) = 314.\n The total frosted area is 1004.8 + 753.6 + 502.4 + 314 = 2888.8 sq cm.\n FINAL ANSWER: 2888.8",
762
  "Computationally flawed"],
763
  ["What is 15% of 200?",
@@ -793,6 +803,18 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()) as app:
793
  outputs=[selector_state, question_input, solution_input],
794
  queue=True,
795
  )
 
 
 
 
 
 
 
 
 
 
 
 
796
 
797
 
798
  app.queue()
 
702
  if not r:
703
  return selector, gr.update(), gr.update()
704
  return selector, r["question"], r["solution"]
705
+
706
+ def _clear_all():
707
+ return (
708
+ "", # question_input
709
+ "", # solution_input
710
+ "", # expected_label_example (hidden)
711
+ "", # classification_output
712
+ "", # explanation_output
713
+ "*(idle)*", # status_output (Markdown)
714
+ )
715
 
716
  components_to_clear = [
717
  question_input,
 
750
  with gr.Row():
751
  classify_btn = gr.Button("Classify Solution", variant="primary")
752
  surprise_btn = gr.Button("Surprise me")
753
+ clear_btn = clear_btn = gr.Button("Clear")
754
 
755
  # -------- Right: outputs --------
756
  with gr.Column(scale=1):
 
767
  ["A rectangle's length is twice its width. If the width is 7 cm, what is the perimeter of the rectangle?",
768
  "The length of the rectangle is 2 * 7 = 14 cm.\n The perimeter is 14 + 7 = 21 cm.\n Final answer: 21",
769
  "Conceptually flawed"],
770
+ ["A baker is making a large cake with three layers. Each layer is a cylinder with a height of 8 cm. The bottom layer has a radius of 20 cm, the middle layer has a radius of 15 cm, and the top layer has a radius of 10 cm. The baker needs to cover the exposed top and side surfaces of the stacked cake with frosting. What is the total surface area to be frosted in square centimeters? Use pi = 3.14.",
771
  "The lateral area of the bottom layer is 2 * 3.14 * 20 * 8 = 1004.8.\n The lateral area of the middle layer is 2 * 3.14 * 15 * 8 = 753.6.\n The lateral area of the top layer is 2 * 3.14 * 10 * 8 = 502.4.\n The exposed top surface is the area of the smallest circle: 3.14 * (10*10) = 314.\n The total frosted area is 1004.8 + 753.6 + 502.4 + 314 = 2888.8 sq cm.\n FINAL ANSWER: 2888.8",
772
  "Computationally flawed"],
773
  ["What is 15% of 200?",
 
803
  outputs=[selector_state, question_input, solution_input],
804
  queue=True,
805
  )
806
+ clear_btn.click(
807
+ fn=_clear_all,
808
+ inputs=[],
809
+ outputs=[
810
+ question_input,
811
+ solution_input,
812
+ expected_label_example,
813
+ classification_output,
814
+ explanation_output,
815
+ status_output,
816
+ ],
817
+ )
818
 
819
 
820
  app.queue()