Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,6 +49,7 @@ description and a Python code snippet, then produce a structured evaluation repo
|
|
| 49 |
- Do NOT execute the code.
|
| 50 |
- Base your evaluation solely on static code analysis and logical reasoning.
|
| 51 |
- Keep feedback concise, clear, and actionable.
|
|
|
|
| 52 |
- Your response MUST follow the output format exactly.
|
| 53 |
### OUTPUT FORMAT
|
| 54 |
Respond only with the following structure β no extra text before or after:
|
|
@@ -266,7 +267,6 @@ def validate_and_evaluate(description: str, code: str):
|
|
| 266 |
# ---------------------------------------------------------------------------
|
| 267 |
# MODULE 1 β UI Module
|
| 268 |
# ---------------------------------------------------------------------------
|
| 269 |
-
|
| 270 |
CUSTOM_CSS = """
|
| 271 |
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');
|
| 272 |
*, *::before, *::after { box-sizing: border-box; }
|
|
@@ -477,29 +477,31 @@ def build_ui(evaluate_fn):
|
|
| 477 |
def _ui_evaluate(description: str, code: str):
|
| 478 |
verdict, metrics, issues, error = evaluate_fn(description, code)
|
| 479 |
accuracy, summary = _split_metrics(metrics)
|
| 480 |
-
|
| 481 |
if error:
|
|
|
|
| 482 |
return (
|
| 483 |
-
gr.update(value="",
|
| 484 |
-
gr.update(value="",
|
| 485 |
-
gr.update(value="",
|
| 486 |
-
gr.update(value="",
|
| 487 |
-
gr.update(value=error, visible=True),
|
| 488 |
)
|
| 489 |
-
|
|
|
|
| 490 |
if "PASS" in verdict.upper():
|
| 491 |
verdict_display = "β
PASS"
|
| 492 |
elif "FAIL" in verdict.upper():
|
| 493 |
verdict_display = "β FAIL"
|
| 494 |
else:
|
| 495 |
verdict_display = verdict or ""
|
| 496 |
-
|
| 497 |
return (
|
| 498 |
-
gr.update(value=verdict_display, visible=True),
|
| 499 |
-
gr.update(value=accuracy, visible=True),
|
| 500 |
-
gr.update(value=summary, visible=True),
|
| 501 |
-
gr.update(value=issues, visible=True),
|
| 502 |
-
gr.update(value="", visible=False),
|
| 503 |
)
|
| 504 |
|
| 505 |
with gr.Blocks(title="Python Code Evaluator") as demo:
|
|
@@ -540,24 +542,32 @@ def build_ui(evaluate_fn):
|
|
| 540 |
|
| 541 |
with gr.Row():
|
| 542 |
eval_btn = gr.Button("Evaluate", variant="primary",
|
| 543 |
-
elem_id="eval-btn",
|
| 544 |
-
clear_btn = gr.Button("Clear",
|
| 545 |
elem_id="clear-btn", scale=0)
|
| 546 |
|
| 547 |
gr.HTML(RESULTS_HEADING_HTML)
|
| 548 |
|
|
|
|
| 549 |
with gr.Row(equal_height=True):
|
| 550 |
-
verdict_out = gr.Textbox(label="Verdict",
|
| 551 |
-
accuracy_out = gr.Textbox(label="Accuracy",
|
| 552 |
-
summary_out = gr.Textbox(label="Summary",
|
| 553 |
-
|
| 554 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
|
| 556 |
with gr.Row():
|
| 557 |
error_out = gr.Textbox(
|
| 558 |
label="Status / Errors",
|
| 559 |
interactive=False,
|
| 560 |
-
visible=False, #
|
| 561 |
elem_id="error-out",
|
| 562 |
scale=1,
|
| 563 |
)
|
|
|
|
| 49 |
- Do NOT execute the code.
|
| 50 |
- Base your evaluation solely on static code analysis and logical reasoning.
|
| 51 |
- Keep feedback concise, clear, and actionable.
|
| 52 |
+
- Pay close attention to operators (+, -, *, /) and ensure they match the description exactly.
|
| 53 |
- Your response MUST follow the output format exactly.
|
| 54 |
### OUTPUT FORMAT
|
| 55 |
Respond only with the following structure β no extra text before or after:
|
|
|
|
| 267 |
# ---------------------------------------------------------------------------
|
| 268 |
# MODULE 1 β UI Module
|
| 269 |
# ---------------------------------------------------------------------------
|
|
|
|
| 270 |
CUSTOM_CSS = """
|
| 271 |
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');
|
| 272 |
*, *::before, *::after { box-sizing: border-box; }
|
|
|
|
| 477 |
def _ui_evaluate(description: str, code: str):
|
| 478 |
verdict, metrics, issues, error = evaluate_fn(description, code)
|
| 479 |
accuracy, summary = _split_metrics(metrics)
|
| 480 |
+
|
| 481 |
if error:
|
| 482 |
+
# Top row stays visible but empty β keeps full width
|
| 483 |
return (
|
| 484 |
+
gr.update(value="", visible=True), # verdict
|
| 485 |
+
gr.update(value="", visible=True), # accuracy
|
| 486 |
+
gr.update(value="", visible=True), # summary
|
| 487 |
+
gr.update(value="", visible=False), # issues β hidden
|
| 488 |
+
gr.update(value=error, visible=True), # error β shown
|
| 489 |
)
|
| 490 |
+
|
| 491 |
+
# Success β show results, hide error
|
| 492 |
if "PASS" in verdict.upper():
|
| 493 |
verdict_display = "β
PASS"
|
| 494 |
elif "FAIL" in verdict.upper():
|
| 495 |
verdict_display = "β FAIL"
|
| 496 |
else:
|
| 497 |
verdict_display = verdict or ""
|
| 498 |
+
|
| 499 |
return (
|
| 500 |
+
gr.update(value=verdict_display, visible=True), # verdict
|
| 501 |
+
gr.update(value=accuracy, visible=True), # accuracy
|
| 502 |
+
gr.update(value=summary, visible=True), # summary
|
| 503 |
+
gr.update(value=issues, visible=True), # issues β shown
|
| 504 |
+
gr.update(value="", visible=False), # error β hidden
|
| 505 |
)
|
| 506 |
|
| 507 |
with gr.Blocks(title="Python Code Evaluator") as demo:
|
|
|
|
| 542 |
|
| 543 |
with gr.Row():
|
| 544 |
eval_btn = gr.Button("Evaluate", variant="primary",
|
| 545 |
+
elem_id="eval-btn", scale=0)
|
| 546 |
+
clear_btn = gr.Button("Clear", variant="secondary",
|
| 547 |
elem_id="clear-btn", scale=0)
|
| 548 |
|
| 549 |
gr.HTML(RESULTS_HEADING_HTML)
|
| 550 |
|
| 551 |
+
# Top row β always visible to preserve full width
|
| 552 |
with gr.Row(equal_height=True):
|
| 553 |
+
verdict_out = gr.Textbox(label="Verdict", interactive=False, elem_id="verdict-out", scale=1)
|
| 554 |
+
accuracy_out = gr.Textbox(label="Accuracy", interactive=False, elem_id="accuracy-out", scale=1)
|
| 555 |
+
summary_out = gr.Textbox(label="Summary", interactive=False, elem_id="summary-out", scale=2, lines=3)
|
| 556 |
+
|
| 557 |
+
# Issues and error swap in the same spot
|
| 558 |
+
issues_out = gr.Textbox(
|
| 559 |
+
label="Issues Detected",
|
| 560 |
+
interactive=False,
|
| 561 |
+
lines=5,
|
| 562 |
+
visible=True,
|
| 563 |
+
elem_id="issues-out",
|
| 564 |
+
)
|
| 565 |
|
| 566 |
with gr.Row():
|
| 567 |
error_out = gr.Textbox(
|
| 568 |
label="Status / Errors",
|
| 569 |
interactive=False,
|
| 570 |
+
visible=False, # hidden by default
|
| 571 |
elem_id="error-out",
|
| 572 |
scale=1,
|
| 573 |
)
|