Avinash250325 commited on
Commit
0261a9b
·
verified ·
1 Parent(s): 0b8a022

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -8,28 +8,24 @@ def generate(context, qtype, difficulty, num, use_beam_search, num_beams):
8
  return f"Error: {str(e)}"
9
 
10
  with gr.Blocks() as demo:
11
- gr.Markdown("# T5 Question Generator")
12
 
13
  with gr.Row():
14
- context = gr.Textbox(label="Context", lines=8, placeholder="Paste your passage here...")
15
 
16
  with gr.Row():
17
  qtype = gr.Dropdown(["short answer", "multiple choice question", "true or false question"], label="Question Type")
18
  difficulty = gr.Dropdown(["easy", "medium", "hard"], label="Difficulty")
19
  num = gr.Slider(1, 5, step=1, label="Number of Questions", value=1)
20
 
21
- use_beam = gr.Checkbox(label="Use Beam Search (only applies when 1 question is generated)", value=False)
22
- # beam_slider = gr.Slider(minimum=3, maximum=6, step=1, value=3, label="Number of Beams")
23
- beam_dropdown = gr.Dropdown(choices=[3, 4, 5, 6], value=3, label="Number of Beams")
24
 
25
-
26
- # Update beam slider visibility dynamically
27
- def show_beam_dropdown(num, beam_flag):
28
- return beam_flag and num == 1
29
-
30
- num.change(fn=show_beam_dropdown, inputs=[num, use_beam], outputs=beam_dropdown, show_progress=False)
31
- use_beam.change(fn=show_beam_dropdown, inputs=[num, use_beam], outputs=beam_dropdown, show_progress=False)
32
 
 
33
 
34
  with gr.Row():
35
  btn = gr.Button("Generate Questions")
 
8
  return f"Error: {str(e)}"
9
 
10
  with gr.Blocks() as demo:
11
+ gr.Markdown("# Finetuned T5Base Question Generator [Descriptive, MCQ, T/F]")
12
 
13
  with gr.Row():
14
+ context = gr.Textbox(label="Context", lines=8, placeholder="Paste your context here...")
15
 
16
  with gr.Row():
17
  qtype = gr.Dropdown(["short answer", "multiple choice question", "true or false question"], label="Question Type")
18
  difficulty = gr.Dropdown(["easy", "medium", "hard"], label="Difficulty")
19
  num = gr.Slider(1, 5, step=1, label="Number of Questions", value=1)
20
 
21
+ with gr.Row(visible=True) as beam_controls:
22
+ use_beam = gr.Checkbox(label="Use Beam Search", value=False)
23
+ beam_dropdown = gr.Dropdown(choices=[3, 4, 5, 6], value=3, label="Number of Beams")
24
 
25
+ def toggle_beam_controls(n):
26
+ return gr.update(visible=(n == 1))
 
 
 
 
 
27
 
28
+ num.change(fn=toggle_beam_controls, inputs=num, outputs=beam_controls)
29
 
30
  with gr.Row():
31
  btn = gr.Button("Generate Questions")