Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -382,85 +382,64 @@ def on_refresh_progress():
|
|
| 382 |
# UI
|
| 383 |
# ---------------------------------------------------------------------------
|
| 384 |
|
| 385 |
-
with gr.Blocks(title="CodeMentor PRO"
|
| 386 |
-
gr.Markdown("# π§βπ» CodeMentor PRO\
|
| 387 |
|
| 388 |
state_last_code = gr.State("")
|
| 389 |
_initial_table, _initial_chart, _initial_summary = get_progress_snapshot()
|
| 390 |
state_last_language = gr.State(SUPPORTED_LANGUAGES[0])
|
| 391 |
state_last_level = gr.State(EXPLANATION_LEVELS[0])
|
| 392 |
|
| 393 |
-
with gr.Tab("
|
| 394 |
with gr.Row():
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
gr.Markdown("### 1. Provide Code")
|
| 398 |
-
code_input = gr.Textbox(label="", lines=12, placeholder="Paste your code here, or upload a screenshot belowβ¦")
|
| 399 |
with gr.Accordion("πΈ Or upload a code screenshot", open=False):
|
| 400 |
-
image_input = gr.Image(label="Code screenshot", type="filepath", height=
|
| 401 |
-
extract_btn = gr.Button("π Extract Code", variant="secondary")
|
| 402 |
-
|
| 403 |
-
gr.
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
cleanup_out = gr.Markdown(value="_Code cleanup suggestions will appear here._")
|
| 431 |
-
with gr.Accordion("β‘ Optimal Solution", open=False):
|
| 432 |
-
optimal_out = gr.Markdown(value="_Optimization review will appear here._")
|
| 433 |
-
|
| 434 |
-
with gr.Tab("π Learning Resources"):
|
| 435 |
-
with gr.Accordion("π Documentation Findings", open=True):
|
| 436 |
-
docs_out = gr.HTML(value="<i>No docs searched yet.</i>")
|
| 437 |
-
with gr.Accordion("π Further Resources", open=True):
|
| 438 |
-
resources_out = gr.HTML(value="<i>No resources searched yet.</i>")
|
| 439 |
-
|
| 440 |
-
with gr.Tab("π₯ Export"):
|
| 441 |
-
gr.Markdown("Download a complete markdown report of this session to save your progress.")
|
| 442 |
-
report_file = gr.File(label="Download Session Report")
|
| 443 |
-
|
| 444 |
-
with gr.Tab("π¬ Chat / Follow-up"):
|
| 445 |
gr.Markdown("Ask follow-up questions about the code you analyzed β I'll remember the context.")
|
| 446 |
chatbot = gr.Chatbot(label="CodeMentor", height=400, value=_greeting_message())
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
chat_send_btn = gr.Button("Send", variant="primary", scale=1)
|
| 450 |
|
| 451 |
-
with gr.Tab("
|
| 452 |
gr.Markdown("Your language-wise revision history and skill breakdown.")
|
| 453 |
-
refresh_btn = gr.Button("π Refresh
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
skill_summary = gr.Markdown(value=_initial_summary)
|
| 462 |
-
with gr.Column(scale=1):
|
| 463 |
-
skill_pie = gr.Plot(value=_initial_chart)
|
| 464 |
|
| 465 |
# ------------------------------ Event wiring ------------------------------
|
| 466 |
|
|
|
|
| 382 |
# UI
|
| 383 |
# ---------------------------------------------------------------------------
|
| 384 |
|
| 385 |
+
with gr.Blocks(title="CodeMentor PRO") as demo:
|
| 386 |
+
gr.Markdown("# π§βπ» CodeMentor PRO\nYour personal, execution-verified coding coach.")
|
| 387 |
|
| 388 |
state_last_code = gr.State("")
|
| 389 |
_initial_table, _initial_chart, _initial_summary = get_progress_snapshot()
|
| 390 |
state_last_language = gr.State(SUPPORTED_LANGUAGES[0])
|
| 391 |
state_last_level = gr.State(EXPLANATION_LEVELS[0])
|
| 392 |
|
| 393 |
+
with gr.Tab("Analyze Code"):
|
| 394 |
with gr.Row():
|
| 395 |
+
with gr.Column(scale=2):
|
| 396 |
+
code_input = gr.Textbox(label="Paste your code", lines=16, placeholder="Paste your code here, or upload a screenshot belowβ¦")
|
|
|
|
|
|
|
| 397 |
with gr.Accordion("πΈ Or upload a code screenshot", open=False):
|
| 398 |
+
image_input = gr.Image(label="Code screenshot", type="filepath", height=240)
|
| 399 |
+
extract_btn = gr.Button("π Extract Code from Image", variant="secondary")
|
| 400 |
+
with gr.Column(scale=1):
|
| 401 |
+
language_dd = gr.Dropdown(SUPPORTED_LANGUAGES, value=SUPPORTED_LANGUAGES[0], label="Language")
|
| 402 |
+
level_dd = gr.Dropdown(EXPLANATION_LEVELS, value=EXPLANATION_LEVELS[0], label="Explanation level")
|
| 403 |
+
plan_btn = gr.Button("1. Preview Plan", variant="primary")
|
| 404 |
+
|
| 405 |
+
plan_output = gr.Markdown(visible=False)
|
| 406 |
+
with gr.Row(visible=False) as plan_actions:
|
| 407 |
+
approve_btn = gr.Button("β
Approve & Run Analysis", variant="primary")
|
| 408 |
+
cancel_btn = gr.Button("β Cancel")
|
| 409 |
+
|
| 410 |
+
with gr.Accordion("π Breakdown", open=True):
|
| 411 |
+
breakdown_out = gr.Markdown()
|
| 412 |
+
with gr.Accordion("π‘ Analogy", open=False):
|
| 413 |
+
analogy_out = gr.Markdown()
|
| 414 |
+
with gr.Accordion("π Errors & Weakness Review", open=True):
|
| 415 |
+
errors_out = gr.Markdown()
|
| 416 |
+
with gr.Accordion("π§Ή Cleanup Diff", open=False):
|
| 417 |
+
cleanup_out = gr.Markdown()
|
| 418 |
+
with gr.Accordion("β‘ Optimal Solution", open=False):
|
| 419 |
+
optimal_out = gr.Markdown()
|
| 420 |
+
with gr.Accordion("π Documentation Findings", open=False):
|
| 421 |
+
docs_out = gr.HTML()
|
| 422 |
+
with gr.Accordion("π Further Resources", open=False):
|
| 423 |
+
resources_out = gr.HTML()
|
| 424 |
+
|
| 425 |
+
report_file = gr.File(label="Download session report")
|
| 426 |
+
|
| 427 |
+
with gr.Tab("Chat / Follow-up"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
gr.Markdown("Ask follow-up questions about the code you analyzed β I'll remember the context.")
|
| 429 |
chatbot = gr.Chatbot(label="CodeMentor", height=400, value=_greeting_message())
|
| 430 |
+
chat_input = gr.Textbox(label="Your question", placeholder="e.g. why did you suggest that fix?")
|
| 431 |
+
chat_send_btn = gr.Button("Send", variant="primary")
|
|
|
|
| 432 |
|
| 433 |
+
with gr.Tab("My Progress"):
|
| 434 |
gr.Markdown("Your language-wise revision history and skill breakdown.")
|
| 435 |
+
refresh_btn = gr.Button("π Refresh")
|
| 436 |
+
revision_table = gr.Dataframe(
|
| 437 |
+
headers=["Language", "Submissions", "Syntax Errors", "Logical Errors", "TLE Count", "Last Seen"],
|
| 438 |
+
value=_initial_table,
|
| 439 |
+
interactive=False,
|
| 440 |
+
)
|
| 441 |
+
skill_pie = gr.Plot(value=_initial_chart)
|
| 442 |
+
skill_summary = gr.Markdown(value=_initial_summary)
|
|
|
|
|
|
|
|
|
|
| 443 |
|
| 444 |
# ------------------------------ Event wiring ------------------------------
|
| 445 |
|