tariqm603 commited on
Commit
ffd1453
·
verified ·
1 Parent(s): a3ba560

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -54,9 +54,9 @@ def gradio_interface(selected_class, selected_subject, selected_chapter, content
54
 
55
  if content is not None and not content.empty:
56
  processed_content = groq_process_data(content)
57
- return processed_content
58
  else:
59
- return "No data available currently."
60
 
61
  # Define the Gradio interface with attractive layout and fresh output page
62
  def run_app():
@@ -83,9 +83,27 @@ def run_app():
83
  with gr.Tab("No Data Available"):
84
  output_message = gr.Textbox() # No data message
85
 
 
 
 
 
86
  # Connecting the button to the output
87
  submit_button.click(gradio_interface, inputs=[selected_class, selected_subject, selected_chapter, content_type], outputs=[output_area, output_message])
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  demo.launch()
90
 
91
  # Run the app
 
54
 
55
  if content is not None and not content.empty:
56
  processed_content = groq_process_data(content)
57
+ return processed_content, "" # Show processed content and no error message
58
  else:
59
+ return None, "No data available currently." # No content found
60
 
61
  # Define the Gradio interface with attractive layout and fresh output page
62
  def run_app():
 
83
  with gr.Tab("No Data Available"):
84
  output_message = gr.Textbox() # No data message
85
 
86
+ # Initially, hide results and error message
87
+ output_area.visible = False
88
+ output_message.visible = False
89
+
90
  # Connecting the button to the output
91
  submit_button.click(gradio_interface, inputs=[selected_class, selected_subject, selected_chapter, content_type], outputs=[output_area, output_message])
92
 
93
+ # Show results only after the button is clicked and hide them initially
94
+ def toggle_output(results, message):
95
+ if results is not None:
96
+ output_area.visible = True
97
+ output_message.visible = False
98
+ return results, ""
99
+ else:
100
+ output_area.visible = False
101
+ output_message.visible = True
102
+ return message,
103
+
104
+ # Show results or message only after button click
105
+ submit_button.click(toggle_output, inputs=[output_area, output_message], outputs=[output_area, output_message])
106
+
107
  demo.launch()
108
 
109
  # Run the app