Upload app.py
Browse files
app.py
CHANGED
|
@@ -415,7 +415,7 @@ def classify_solution_stream(question: str, solution: str, progress=gr.Progress(
|
|
| 415 |
yield "Runtime error", f"{type(e).__name__}: {e}", "❌ Exception during inference."
|
| 416 |
|
| 417 |
|
| 418 |
-
|
| 419 |
with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()) as app:
|
| 420 |
gr.Markdown("# 🧮 Math Solution Classifier")
|
| 421 |
gr.Markdown(
|
|
@@ -449,31 +449,25 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()) as app:
|
|
| 449 |
# ---------- Examples ----------
|
| 450 |
gr.Examples(
|
| 451 |
examples=[
|
| 452 |
-
[
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
[
|
| 457 |
-
|
| 458 |
-
"They have 7 + 3 = 11 apples.",
|
| 459 |
-
],
|
| 460 |
-
[
|
| 461 |
-
"What is 15% of 200?",
|
| 462 |
-
"15% = 15/100 = 0.15\n0.15 × 200 = 30",
|
| 463 |
-
],
|
| 464 |
],
|
| 465 |
inputs=[question_input, solution_input],
|
| 466 |
)
|
| 467 |
|
| 468 |
# ---------- Wiring ----------
|
| 469 |
classify_btn.click(
|
| 470 |
-
fn=classify_solution_stream,
|
| 471 |
inputs=[question_input, solution_input],
|
| 472 |
outputs=[classification_output, explanation_output, status_output],
|
| 473 |
-
show_progress="
|
|
|
|
| 474 |
)
|
| 475 |
|
| 476 |
-
# Clear everything
|
| 477 |
clear_btn.click(
|
| 478 |
lambda: ("", "", "", "", "*(idle)*"),
|
| 479 |
inputs=None,
|
|
@@ -487,8 +481,10 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()) as app:
|
|
| 487 |
queue=False,
|
| 488 |
)
|
| 489 |
|
| 490 |
-
# Enable queue
|
| 491 |
-
app.queue(
|
| 492 |
|
| 493 |
if __name__ == "__main__":
|
| 494 |
app.launch()
|
|
|
|
|
|
|
|
|
| 415 |
yield "Runtime error", f"{type(e).__name__}: {e}", "❌ Exception during inference."
|
| 416 |
|
| 417 |
|
| 418 |
+
# Create Gradio interface (streaming UI)
|
| 419 |
with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()) as app:
|
| 420 |
gr.Markdown("# 🧮 Math Solution Classifier")
|
| 421 |
gr.Markdown(
|
|
|
|
| 449 |
# ---------- Examples ----------
|
| 450 |
gr.Examples(
|
| 451 |
examples=[
|
| 452 |
+
["Solve for x: 2x + 5 = 13",
|
| 453 |
+
"2x + 5 = 13\n2x = 13 - 5\n2x = 8\nx = 4"],
|
| 454 |
+
["John has three apples and Mary has seven, how many apples do they have together?",
|
| 455 |
+
"They have 7 + 3 = 11 apples."],
|
| 456 |
+
["What is 15% of 200?",
|
| 457 |
+
"15% = 15/100 = 0.15\n0.15 × 200 = 30"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
],
|
| 459 |
inputs=[question_input, solution_input],
|
| 460 |
)
|
| 461 |
|
| 462 |
# ---------- Wiring ----------
|
| 463 |
classify_btn.click(
|
| 464 |
+
fn=classify_solution_stream, # your generator
|
| 465 |
inputs=[question_input, solution_input],
|
| 466 |
outputs=[classification_output, explanation_output, status_output],
|
| 467 |
+
show_progress="minimal", # single compact global bar
|
| 468 |
+
concurrency_limit=1, # <- set per-event, not in app.queue()
|
| 469 |
)
|
| 470 |
|
|
|
|
| 471 |
clear_btn.click(
|
| 472 |
lambda: ("", "", "", "", "*(idle)*"),
|
| 473 |
inputs=None,
|
|
|
|
| 481 |
queue=False,
|
| 482 |
)
|
| 483 |
|
| 484 |
+
# Enable queue without deprecated args (or omit entirely if you like)
|
| 485 |
+
app.queue()
|
| 486 |
|
| 487 |
if __name__ == "__main__":
|
| 488 |
app.launch()
|
| 489 |
+
|
| 490 |
+
|