Upload app.py
Browse files
app.py
CHANGED
@@ -415,9 +415,8 @@ 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 |
# Create Gradio interface (streaming UI)
|
420 |
-
with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft()
|
421 |
gr.Markdown("# 🧮 Math Solution Classifier")
|
422 |
gr.Markdown(
|
423 |
"Classify math solutions as **correct**, **conceptually flawed**, or **computationally flawed**. "
|
@@ -444,8 +443,8 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft(), queue=T
|
|
444 |
# ---------- Right: outputs ----------
|
445 |
with gr.Column(scale=1):
|
446 |
classification_output = gr.Textbox(label="Classification", interactive=False)
|
447 |
-
explanation_output
|
448 |
-
status_output
|
449 |
|
450 |
# ---------- Examples ----------
|
451 |
gr.Examples(
|
@@ -468,10 +467,10 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft(), queue=T
|
|
468 |
|
469 |
# ---------- Wiring ----------
|
470 |
classify_btn.click(
|
471 |
-
fn=classify_solution_stream,
|
472 |
inputs=[question_input, solution_input],
|
473 |
outputs=[classification_output, explanation_output, status_output],
|
474 |
-
show_progress="hidden",
|
475 |
)
|
476 |
|
477 |
# Clear everything
|
@@ -488,5 +487,8 @@ with gr.Blocks(title="Math Solution Classifier", theme=gr.themes.Soft(), queue=T
|
|
488 |
queue=False,
|
489 |
)
|
490 |
|
|
|
|
|
|
|
491 |
if __name__ == "__main__":
|
492 |
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(
|
422 |
"Classify math solutions as **correct**, **conceptually flawed**, or **computationally flawed**. "
|
|
|
443 |
# ---------- Right: outputs ----------
|
444 |
with gr.Column(scale=1):
|
445 |
classification_output = gr.Textbox(label="Classification", interactive=False)
|
446 |
+
explanation_output = gr.Textbox(label="Explanation", interactive=False, lines=6)
|
447 |
+
status_output = gr.Markdown(value="*(idle)*") # live stage updates
|
448 |
|
449 |
# ---------- Examples ----------
|
450 |
gr.Examples(
|
|
|
467 |
|
468 |
# ---------- Wiring ----------
|
469 |
classify_btn.click(
|
470 |
+
fn=classify_solution_stream, # your generator
|
471 |
inputs=[question_input, solution_input],
|
472 |
outputs=[classification_output, explanation_output, status_output],
|
473 |
+
show_progress="hidden", # single compact global bar
|
474 |
)
|
475 |
|
476 |
# Clear everything
|
|
|
487 |
queue=False,
|
488 |
)
|
489 |
|
490 |
+
# Enable queue AFTER building (needed for streaming on Spaces)
|
491 |
+
app.queue(concurrency_count=1, max_size=16)
|
492 |
+
|
493 |
if __name__ == "__main__":
|
494 |
app.launch()
|