Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from backend import process_pdf
|
| 3 |
+
|
| 4 |
+
with gr.Blocks() as demo:
|
| 5 |
+
gr.Markdown("## 📘 AI-Powered Question Generator from Textbook PDFs")
|
| 6 |
+
|
| 7 |
+
with gr.Row():
|
| 8 |
+
pdf_input = gr.File(label="Upload Textbook PDF", file_types=[".pdf"])
|
| 9 |
+
tag_input = gr.Dropdown(
|
| 10 |
+
label="Question Type",
|
| 11 |
+
choices=["short answer", "long answer", "true or false", "multiple choice question"],
|
| 12 |
+
value="short answer"
|
| 13 |
+
)
|
| 14 |
+
difficulty_input = gr.Dropdown(
|
| 15 |
+
label="Difficulty",
|
| 16 |
+
choices=["easy", "medium", "hard"],
|
| 17 |
+
value="medium"
|
| 18 |
+
)
|
| 19 |
+
query_input = gr.Textbox(label="Enter your query")
|
| 20 |
+
|
| 21 |
+
generate_button = gr.Button("Generate Questions")
|
| 22 |
+
output_text = gr.Textbox(label="Generated Questions", lines=10)
|
| 23 |
+
|
| 24 |
+
generate_button.click(
|
| 25 |
+
fn=process_pdf,
|
| 26 |
+
inputs=[pdf_input, tag_input, difficulty_input, query_input],
|
| 27 |
+
outputs=output_text
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
demo.launch()
|