Mustafa Başar commited on
Commit
bd81c6e
·
verified ·
1 Parent(s): fcf9a0e

Upload 17 files

Browse files
Files changed (1) hide show
  1. app.py +42 -44
app.py CHANGED
@@ -622,46 +622,11 @@ with gr.Blocks(theme=gr.themes.Soft(), title="PromptMaster for Data Analytics")
622
 
623
  # Modify the show_answer_toggle functionality
624
  show_answer_toggle.change(
625
- lambda show: gr.update(value=f"### Model Solution\n\n{answer_output.value}") if show else gr.update(value=""),
626
- inputs=[show_answer_toggle],
627
  outputs=[evaluation_output]
628
  )
629
 
630
- # Logic for displaying answers immediately if toggle is on
631
- def handle_show_answer(title, description, level, category,
632
- table1_visible, table2_visible, table3_visible,
633
- table1_label, table2_label, table3_label,
634
- table1_html, table2_html, table3_html,
635
- answer, show_immediately):
636
- # Just pass through all values except evaluation_output
637
- if show_immediately:
638
- # Create a fake evaluation to show the answer
639
- fake_eval = f"### Model Solution\n\n{answer}"
640
- return [title, description, level, category,
641
- gr.update(visible=table1_visible),
642
- gr.update(visible=table2_visible),
643
- gr.update(visible=table3_visible),
644
- gr.update(value=table1_label),
645
- gr.update(value=table2_label),
646
- gr.update(value=table3_label),
647
- gr.update(value=table1_html),
648
- gr.update(value=table2_html),
649
- gr.update(value=table3_html),
650
- answer, fake_eval]
651
- else:
652
- # Don't show the answer yet
653
- return [title, description, level, category,
654
- gr.update(visible=table1_visible),
655
- gr.update(visible=table2_visible),
656
- gr.update(visible=table3_visible),
657
- gr.update(value=table1_label),
658
- gr.update(value=table2_label),
659
- gr.update(value=table3_label),
660
- gr.update(value=table1_html),
661
- gr.update(value=table2_html),
662
- gr.update(value=table3_html),
663
- answer, ""]
664
-
665
  # Logic
666
  new_scenario_btn.click(
667
  get_new_scenario,
@@ -671,9 +636,20 @@ with gr.Blocks(theme=gr.themes.Soft(), title="PromptMaster for Data Analytics")
671
  sample_table1, sample_table2, sample_table3,
672
  answer_output]
673
  ).then(
674
- handle_show_answer,
 
 
 
 
 
 
 
 
 
 
 
675
  inputs=[title_output, description_output, level_output, category_output,
676
- table_row, table_row2, table_row3,
677
  sample_table1_label, sample_table2_label, sample_table3_label,
678
  sample_table1, sample_table2, sample_table3,
679
  answer_output, show_answer_toggle],
@@ -692,9 +668,20 @@ with gr.Blocks(theme=gr.themes.Soft(), title="PromptMaster for Data Analytics")
692
  sample_table1, sample_table2, sample_table3,
693
  answer_output]
694
  ).then(
695
- handle_show_answer,
 
 
 
 
 
 
 
 
 
 
 
696
  inputs=[title_output, description_output, level_output, category_output,
697
- table_row, table_row2, table_row3,
698
  sample_table1_label, sample_table2_label, sample_table3_label,
699
  sample_table1, sample_table2, sample_table3,
700
  answer_output, show_answer_toggle],
@@ -713,9 +700,20 @@ with gr.Blocks(theme=gr.themes.Soft(), title="PromptMaster for Data Analytics")
713
  sample_table1, sample_table2, sample_table3,
714
  answer_output]
715
  ).then(
716
- handle_show_answer,
 
 
 
 
 
 
 
 
 
 
 
717
  inputs=[title_output, description_output, level_output, category_output,
718
- table_row, table_row2, table_row3,
719
  sample_table1_label, sample_table2_label, sample_table3_label,
720
  sample_table1, sample_table2, sample_table3,
721
  answer_output, show_answer_toggle],
@@ -789,4 +787,4 @@ with gr.Blocks(theme=gr.themes.Soft(), title="PromptMaster for Data Analytics")
789
  """)
790
 
791
  # Launch the app
792
- app.launch()
 
622
 
623
  # Modify the show_answer_toggle functionality
624
  show_answer_toggle.change(
625
+ lambda show, answer: gr.update(value=f"### Model Solution\n\n{answer}") if show else gr.update(value=""),
626
+ inputs=[show_answer_toggle, answer_output],
627
  outputs=[evaluation_output]
628
  )
629
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
630
  # Logic
631
  new_scenario_btn.click(
632
  get_new_scenario,
 
636
  sample_table1, sample_table2, sample_table3,
637
  answer_output]
638
  ).then(
639
+ lambda title, desc, level, category, table1_vis, table2_vis, table3_vis, label1, label2, label3, content1, content2, content3, answer, show_immediately: (
640
+ [
641
+ title, desc, level, category,
642
+ gr.update(visible=table1_vis),
643
+ gr.update(visible=table2_vis),
644
+ gr.update(visible=table3_vis),
645
+ label1, label2, label3,
646
+ content1, content2, content3,
647
+ answer,
648
+ f"### Model Solution\n\n{answer}" if show_immediately else ""
649
+ ]
650
+ ),
651
  inputs=[title_output, description_output, level_output, category_output,
652
+ table_row, table_row2, table_row3,
653
  sample_table1_label, sample_table2_label, sample_table3_label,
654
  sample_table1, sample_table2, sample_table3,
655
  answer_output, show_answer_toggle],
 
668
  sample_table1, sample_table2, sample_table3,
669
  answer_output]
670
  ).then(
671
+ lambda title, desc, level, category, table1_vis, table2_vis, table3_vis, label1, label2, label3, content1, content2, content3, answer, show_immediately: (
672
+ [
673
+ title, desc, level, category,
674
+ gr.update(visible=table1_vis),
675
+ gr.update(visible=table2_vis),
676
+ gr.update(visible=table3_vis),
677
+ label1, label2, label3,
678
+ content1, content2, content3,
679
+ answer,
680
+ f"### Model Solution\n\n{answer}" if show_immediately else ""
681
+ ]
682
+ ),
683
  inputs=[title_output, description_output, level_output, category_output,
684
+ table_row, table_row2, table_row3,
685
  sample_table1_label, sample_table2_label, sample_table3_label,
686
  sample_table1, sample_table2, sample_table3,
687
  answer_output, show_answer_toggle],
 
700
  sample_table1, sample_table2, sample_table3,
701
  answer_output]
702
  ).then(
703
+ lambda title, desc, level, category, table1_vis, table2_vis, table3_vis, label1, label2, label3, content1, content2, content3, answer, show_immediately: (
704
+ [
705
+ title, desc, level, category,
706
+ gr.update(visible=table1_vis),
707
+ gr.update(visible=table2_vis),
708
+ gr.update(visible=table3_vis),
709
+ label1, label2, label3,
710
+ content1, content2, content3,
711
+ answer,
712
+ f"### Model Solution\n\n{answer}" if show_immediately else ""
713
+ ]
714
+ ),
715
  inputs=[title_output, description_output, level_output, category_output,
716
+ table_row, table_row2, table_row3,
717
  sample_table1_label, sample_table2_label, sample_table3_label,
718
  sample_table1, sample_table2, sample_table3,
719
  answer_output, show_answer_toggle],
 
787
  """)
788
 
789
  # Launch the app
790
+ app.launch(share=False, debug=True)