mnawfal29 commited on
Commit
70c8404
·
verified ·
1 Parent(s): 0945a7e

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. demo/ui.py +146 -30
demo/ui.py CHANGED
@@ -755,6 +755,101 @@ footer, .gradio-container footer { display: none !important; }
755
  opacity: 0.6;
756
  }
757
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
758
  /* Main pane plots+outputs */
759
  .gradio-container .gr-plot, .gradio-container .plot-wrap {
760
  background: var(--lf-surface-alt) !important;
@@ -1383,41 +1478,62 @@ def _llm_auto_run(endpoint_choice, custom_url, api_key, model_name,
1383
  else:
1384
  action_str = "commit"
1385
 
1386
- # Pretty last-result line
 
 
 
 
 
1387
  lar = obs.last_action_result or {}
1388
- feedback = lar.get("feedback")
1389
- pretty = []
1390
- if "compile_error" in lar and lar["compile_error"]:
1391
- pretty.append(f"❌ compile error")
1392
- if "summary" in lar and lar.get("summary"):
1393
  s = lar["summary"]
1394
- if s.get("converged"): pretty.append("✅ auto-test converged")
1395
- elif s.get("diverged"): pretty.append("⚠ auto-test diverged")
 
 
 
 
1396
  if s.get("final_f") is not None:
1397
- pretty.append(f"final_f={s['final_f']:.3g}")
1398
- if feedback:
1399
- for k, v in feedback.items():
1400
- pretty.append(f"{k}={v:+.3f}")
1401
- if "final_f" in lar and action.kind == "run_baseline":
1402
- pretty.append(f"final_f={lar['final_f']:.3g}")
1403
- result_hint = " · ".join(pretty) if pretty else "ok"
1404
-
1405
- # Build the turn header. Using a span-with-class instead of inline
1406
- # backticks so the action kind doesn't render as a sienna pill.
1407
- kind_chip = (f"<span class='lf-chip lf-chip-{action.kind}'>"
1408
- f"{action.kind}</span>")
1409
- log_lines.extend([
1410
- f"",
1411
- f"<hr class='lf-hr-soft' />",
1412
- f"**Turn {turn}** · {kind_chip} · {dt:.1f}s · "
1413
- f"budget **{obs.budget_remaining}** ",
1414
- f" {action_str} ",
1415
- f"{result_hint}",
1416
- f"", # blank line before fence — critical for markdown parsing
1417
- ])
 
 
 
 
 
 
 
 
 
 
 
 
 
1418
  if action.kind == "draft" and action.code:
1419
  log_lines.append(f"```python\n{action.code.strip()}\n```")
1420
- log_lines.append(f"") # blank line after
1421
 
1422
  yield ("\n".join(log_lines), obs.model_dump(exclude_none=True), None)
1423
 
 
755
  opacity: 0.6;
756
  }
757
 
758
+ /* Turn card — one per REPL step. Clearly demarcates Action vs Output */
759
+ .gradio-container .lf-turn {
760
+ background: var(--lf-surface);
761
+ border: 1px solid var(--lf-border);
762
+ border-radius: 10px;
763
+ padding: 0.9rem 1rem;
764
+ margin: 0.85rem 0;
765
+ box-shadow: 0 1px 0 rgba(0,0,0,0.2);
766
+ }
767
+ .gradio-container .lf-turn-head {
768
+ display: flex; align-items: center; gap: 0.55rem;
769
+ margin-bottom: 0.7rem;
770
+ padding-bottom: 0.55rem;
771
+ border-bottom: 1px dashed var(--lf-border-soft);
772
+ }
773
+ .gradio-container .lf-turn-num {
774
+ font-family: "Source Serif 4", Georgia, serif;
775
+ font-weight: 600;
776
+ font-size: 0.98rem;
777
+ color: var(--lf-text);
778
+ letter-spacing: -0.01em;
779
+ }
780
+ .gradio-container .lf-turn-meta {
781
+ margin-left: auto;
782
+ font-family: "JetBrains Mono", monospace;
783
+ font-size: 0.76rem;
784
+ color: var(--lf-text-subtle);
785
+ }
786
+ .gradio-container .lf-turn-meta b {
787
+ color: var(--lf-text);
788
+ font-weight: 600;
789
+ }
790
+ .gradio-container .lf-turn-row {
791
+ display: grid;
792
+ grid-template-columns: 70px 1fr;
793
+ align-items: baseline;
794
+ gap: 0.75rem;
795
+ padding: 0.25rem 0;
796
+ }
797
+ .gradio-container .lf-section-label {
798
+ font-family: "Inter", sans-serif;
799
+ font-size: 0.68rem;
800
+ font-weight: 600;
801
+ letter-spacing: 0.1em;
802
+ text-transform: uppercase;
803
+ color: var(--lf-text-subtle);
804
+ padding-top: 0.15rem;
805
+ }
806
+ .gradio-container .lf-section-content {
807
+ color: var(--lf-text);
808
+ font-size: 0.9rem;
809
+ line-height: 1.55;
810
+ font-family: "Inter", sans-serif;
811
+ }
812
+ .gradio-container .lf-section-content code {
813
+ font-size: 0.82em !important;
814
+ }
815
+ .gradio-container .lf-section-content b {
816
+ color: var(--lf-text);
817
+ font-weight: 600;
818
+ }
819
+
820
+ /* Status chips inside the Output row */
821
+ .gradio-container .lf-status {
822
+ display: inline-block;
823
+ padding: 0.05rem 0.45rem;
824
+ border-radius: 4px;
825
+ font-size: 0.78rem;
826
+ font-weight: 500;
827
+ border: 1px solid;
828
+ background: transparent;
829
+ margin-right: 0.15rem;
830
+ }
831
+ .gradio-container .lf-status-good {
832
+ color: #7ab68c;
833
+ border-color: rgba(122,182,140,0.4);
834
+ background: rgba(122,182,140,0.08);
835
+ }
836
+ .gradio-container .lf-status-warn {
837
+ color: #e4b264;
838
+ border-color: rgba(228,178,100,0.4);
839
+ background: rgba(228,178,100,0.08);
840
+ }
841
+ .gradio-container .lf-status-bad {
842
+ color: #d47d6a;
843
+ border-color: rgba(212,125,106,0.4);
844
+ background: rgba(212,125,106,0.08);
845
+ }
846
+
847
+ /* Code fence that follows a turn card — tighten top margin */
848
+ .gradio-container .lf-turn + pre,
849
+ .gradio-container .prose pre:has(+ .lf-turn) {
850
+ margin-top: -0.5rem !important;
851
+ }
852
+
853
  /* Main pane plots+outputs */
854
  .gradio-container .gr-plot, .gradio-container .plot-wrap {
855
  background: var(--lf-surface-alt) !important;
 
1478
  else:
1479
  action_str = "commit"
1480
 
1481
+ # Build a self-contained "turn card" with explicit Action / Output
1482
+ # demarcation. Rendered as HTML so we control the structure.
1483
+ kind_chip = (f"<span class='lf-chip lf-chip-{action.kind}'>"
1484
+ f"{action.kind}</span>")
1485
+ # Output status badges — colored chips + key/value pairs.
1486
+ output_badges: list[str] = []
1487
  lar = obs.last_action_result or {}
1488
+ if lar.get("compile_error"):
1489
+ output_badges.append(
1490
+ "<span class='lf-status lf-status-bad'>compile error</span>")
1491
+ if lar.get("summary"):
 
1492
  s = lar["summary"]
1493
+ if s.get("converged"):
1494
+ output_badges.append(
1495
+ "<span class='lf-status lf-status-good'>auto-test converged</span>")
1496
+ elif s.get("diverged"):
1497
+ output_badges.append(
1498
+ "<span class='lf-status lf-status-warn'>auto-test diverged</span>")
1499
  if s.get("final_f") is not None:
1500
+ output_badges.append(
1501
+ f"<code>final_f</code> = <b>{s['final_f']:.3g}</b>")
1502
+ if action.kind == "run_baseline" and lar.get("final_f") is not None:
1503
+ output_badges.append(
1504
+ f"<code>final_f</code> = <b>{lar['final_f']:.3g}</b>")
1505
+ fb = lar.get("feedback") or {}
1506
+ for k, v in fb.items():
1507
+ cls = "lf-status-good" if v >= 0 else "lf-status-warn"
1508
+ output_badges.append(
1509
+ f"<span class='lf-status {cls}'><code>{k}</code> "
1510
+ f"<b>{v:+.3f}</b></span>")
1511
+
1512
+ output_html = " · ".join(output_badges) if output_badges else "ok"
1513
+
1514
+ turn_html = (
1515
+ f"<div class='lf-turn'>"
1516
+ f" <div class='lf-turn-head'>"
1517
+ f" <span class='lf-turn-num'>Turn {turn}</span>"
1518
+ f" {kind_chip}"
1519
+ f" <span class='lf-turn-meta'>{dt:.1f}s · budget "
1520
+ f"<b>{obs.budget_remaining}</b></span>"
1521
+ f" </div>"
1522
+ f" <div class='lf-turn-row'>"
1523
+ f" <div class='lf-section-label'>Action</div>"
1524
+ f" <div class='lf-section-content'>{action_str}</div>"
1525
+ f" </div>"
1526
+ f" <div class='lf-turn-row'>"
1527
+ f" <div class='lf-section-label'>Output</div>"
1528
+ f" <div class='lf-section-content'>{output_html}</div>"
1529
+ f" </div>"
1530
+ f"</div>"
1531
+ )
1532
+ log_lines.extend([f"", turn_html, f""])
1533
+
1534
  if action.kind == "draft" and action.code:
1535
  log_lines.append(f"```python\n{action.code.strip()}\n```")
1536
+ log_lines.append(f"")
1537
 
1538
  yield ("\n".join(log_lines), obs.model_dump(exclude_none=True), None)
1539