Avinash250325 commited on
Commit
62f90c5
·
verified ·
1 Parent(s): fe6431b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py CHANGED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from backend import generate_questions
3
+
4
+ def generate(context, qtype, difficulty, num):
5
+ try:
6
+ return "\n\n".join(generate_questions(context, qtype, difficulty, num))
7
+ except Exception as e:
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", "true/false"], 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():
22
+ btn = gr.Button("Generate Questions")
23
+
24
+ output = gr.Textbox(label="Generated Questions", lines=10)
25
+
26
+ btn.click(fn=generate, inputs=[context, qtype, difficulty, num], outputs=output)
27
+
28
+ if __name__ == "__main__":
29
+ demo.launch()