Update app.py
Browse files
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("#
|
| 12 |
|
| 13 |
with gr.Row():
|
| 14 |
-
context = gr.Textbox(label="Context", lines=8, placeholder="Paste your
|
| 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 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 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")
|