Urvxshhhhh0201 commited on
Commit
d1cc50d
Β·
verified Β·
1 Parent(s): 4735c11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -67
app.py CHANGED
@@ -382,85 +382,64 @@ def on_refresh_progress():
382
  # UI
383
  # ---------------------------------------------------------------------------
384
 
385
- with gr.Blocks(title="CodeMentor PRO", theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue")) as demo:
386
- gr.Markdown("# πŸ§‘β€πŸ’» CodeMentor PRO\n**Your 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
- # Left Pane: Input and Setup
396
- with gr.Column(scale=4):
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=200)
401
- extract_btn = gr.Button("πŸ” Extract Code", variant="secondary")
402
-
403
- gr.Markdown("### 2. Configuration")
404
- with gr.Row():
405
- language_dd = gr.Dropdown(SUPPORTED_LANGUAGES, value=SUPPORTED_LANGUAGES[0], label="Language", scale=1)
406
- level_dd = gr.Dropdown(EXPLANATION_LEVELS, value=EXPLANATION_LEVELS[0], label="Explanation Level", scale=1)
407
-
408
- plan_btn = gr.Button("3. Preview Plan", variant="primary")
409
-
410
- plan_output = gr.Markdown(visible=False)
411
- with gr.Row(visible=False) as plan_actions:
412
- approve_btn = gr.Button("βœ… Approve & Run", variant="primary")
413
- cancel_btn = gr.Button("❌ Cancel")
414
-
415
- # Right Pane: Results
416
- with gr.Column(scale=8):
417
- gr.Markdown("### πŸ“Š Analysis Results")
418
- with gr.Tabs():
419
- with gr.Tab("πŸ“– Explanation"):
420
- gr.Markdown("#### Breakdown")
421
- breakdown_out = gr.Markdown(value="_Run an analysis to see the line-by-line breakdown._")
422
- gr.Markdown("---")
423
- gr.Markdown("#### πŸ’‘ Analogy")
424
- analogy_out = gr.Markdown(value="_Analogy will appear here._")
425
-
426
- with gr.Tab("🐞 Diagnostics & Code"):
427
- with gr.Accordion("🚨 Errors & Weakness Review", open=True):
428
- errors_out = gr.Markdown(value="_No error data yet._")
429
- with gr.Accordion("🧹 Cleanup Diff", open=False):
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
- with gr.Row():
448
- chat_input = gr.Textbox(label="Your question", placeholder="e.g. why did you suggest that fix?", scale=4)
449
- chat_send_btn = gr.Button("Send", variant="primary", scale=1)
450
 
451
- with gr.Tab("πŸ“ˆ My Progress"):
452
  gr.Markdown("Your language-wise revision history and skill breakdown.")
453
- refresh_btn = gr.Button("πŸ”„ Refresh Data")
454
- with gr.Row():
455
- with gr.Column(scale=1):
456
- revision_table = gr.Dataframe(
457
- headers=["Language", "Submissions", "Syntax Errors", "Logical Errors", "TLE Count", "Last Seen"],
458
- value=_initial_table,
459
- interactive=False,
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