Spaces:
Sleeping
Sleeping
|
Download UI.md from shashanks/medical_coding: direct link, hf CLI and curl.
- Browser
- Download file 6.61 kB
-
https://huggingface.co/spaces/shashanks/medical_coding/resolve/main/UI.md
- Command line
-
hf download hf://spaces/shashanks/medical_coding/UI.md
-
curl -L -o UI.md https://huggingface.co/spaces/shashanks/medical_coding/resolve/main/UI.md
6.61 kB
| # Medical Coding Auditor β UI Analysis & Improvement Plan | |
| ## Why Our UI Looked the Same (Root Cause Analysis) | |
| ### Problem 1: Wrong CSS injection point | |
| | | Reference (sre-incident-env / Gradio 4.x) | Our implementation (Gradio 6.11) | | |
| |---|---|---| | |
| | CSS injection | `gr.Blocks(css=CUSTOM_CSS)` | `mount_gradio_app(..., css=CSS)` | | |
| In **Gradio 6.x** the `css=` parameter moved from `gr.Blocks()` to `mount_gradio_app()`. | |
| Passing `css=` to `gr.Blocks()` emits a deprecation warning and is silently ignored | |
| (the blocks's `.css` attribute stays `None`). Verified against Gradio 6.11.0. | |
| The correct Gradio 6.x pattern is: | |
| ```python | |
| # gradio_landing.py | |
| CSS = "..." # plain string, no <style> tags | |
| def create_gradio_app(): | |
| with gr.Blocks(title="...") as demo: # NO css= here in Gradio 6.x | |
| ... | |
| return demo | |
| # app.py | |
| gradio_app = create_gradio_app() | |
| app = gr.mount_gradio_app(app, gradio_app, path="/", css=CSS) # css= goes HERE | |
| ``` | |
| ### Problem 2: Missing Gradio container overrides | |
| Our CSS only defined custom classes (`.hero`, `.card`, etc.) but never overrode Gradio's | |
| default container styling. The reference CSS starts with: | |
| ```css | |
| html, body, .gradio-container { | |
| background: #0a0a0a !important; | |
| color: #ededed !important; | |
| font-family: "Inter", -apple-system, ...; | |
| -webkit-font-smoothing: antialiased; | |
| } | |
| .gradio-container .block { | |
| background: transparent !important; | |
| border: none !important; | |
| box-shadow: none !important; | |
| padding: 0 !important; | |
| } | |
| ``` | |
| Without these, Gradio's own theme renders as the "frame" around the custom HTML, | |
| so the custom classes only style their immediate content while the Gradio chrome | |
| (background, panels, dropdowns) looks unmodified. | |
| ### Problem 3: Mount path was wrong initially | |
| We originally mounted at `/ui` instead of `/`. The reference always mounts at `/` | |
| so the Gradio UI is the first thing visitors see. Fixed. | |
| --- | |
| ## Reference Architecture (sre-incident-env) | |
| ```python | |
| # server/app.py β how the reference does it | |
| CUSTOM_CSS = "..." # ~200 lines, plain CSS string, NO <style> tags | |
| def create_landing_app(): | |
| with gr.Blocks(css=CUSTOM_CSS) as demo: # <-- CSS goes HERE | |
| ... | |
| return demo | |
| app = gr.mount_gradio_app(app, _landing_app, path="/") # NO css= here | |
| ``` | |
| ### Reference CSS scope | |
| The reference CSS (~200 lines) has three layers: | |
| 1. **Gradio container overrides** β forces dark background, font, removes default panels: | |
| ```css | |
| html, body, .gradio-container { background: #0a0a0a !important; ... } | |
| .gradio-container .block { background: transparent !important; border: none !important; } | |
| .gradio-container .form, .gradio-container .panel { background: transparent !important; } | |
| ``` | |
| 2. **Component-level overrides** β dropdowns, textboxes, buttons: | |
| ```css | |
| .gradio-container select, .gradio-container input, .gradio-container textarea { | |
| background: #0a0a0a !important; border: 1px solid #262626 !important; color: #ededed !important; | |
| } | |
| .gradio-container button { background: #141414 !important; border: 1px solid #262626 !important; } | |
| .gradio-container button.primary { background: #00d084 !important; color: #0a0a0a !important; } | |
| ``` | |
| 3. **Custom class definitions** β `.hero`, `.card`, `.scenario`, `.lb`, `.pg-*`: | |
| These only work AFTER the container overrides establish the dark background. | |
| --- | |
| ## What Our Fixed Implementation Does | |
| ### CSS approach (fixed) | |
| ```python | |
| # gradio_landing.py | |
| CSS = """ | |
| html, body, .gradio-container { | |
| background: #0a0a0a !important; | |
| color: #ededed !important; | |
| font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important; | |
| -webkit-font-smoothing: antialiased; | |
| } | |
| .gradio-container .block, .gradio-container .panel, .gradio-container .form { | |
| background: transparent !important; | |
| border: none !important; | |
| box-shadow: none !important; | |
| padding: 0 !important; | |
| } | |
| /* ... then our custom classes ... */ | |
| .hero { background: #141414; border: 1px solid #262626; border-radius: 12px; ... } | |
| """ | |
| def create_gradio_app() -> gr.Blocks: | |
| with gr.Blocks(css=CSS, title="...") as demo: # CSS passed here | |
| ... | |
| ``` | |
| ### app.py (fixed) | |
| ```python | |
| from .gradio_landing import create_gradio_app # no CSS import needed | |
| gradio_app = create_gradio_app() | |
| app = gr.mount_gradio_app(app, gradio_app, path="/") # no css= param | |
| ``` | |
| ### Tab structure (5 tabs matching reference quality) | |
| 1. **Overview** β Hero stats + 6 uniqueness cards + 5 scenario cards | |
| 2. **Rewards** β Full reward table with all 18 signals | |
| 3. **Leaderboard** β Color-coded score table with tier badges | |
| 4. **Playground** β Interactive episode runner with live HTML status | |
| 5. **Try It** β Code examples for inference.py and session API | |
| ### Design palette (medical blue, adapted from reference emerald) | |
| ``` | |
| bg: #0a0a0a (near-black) | |
| surface: #141414 (cards) | |
| surface-2: #1a1a1a (nested elements) | |
| border: #262626 (subtle dividers) | |
| text: #ededed (primary) | |
| muted: #9ca3af (secondary) | |
| accent: #3b82f6 (medical blue β vs emerald in sre-incident-env) | |
| success: #22c55e | |
| warning: #f59e0b | |
| danger: #ef4444 | |
| ``` | |
| --- | |
| ## Remaining Differences vs Reference | |
| | Feature | Reference | Ours | Gap | | |
| |---|---|---|---| | |
| | Mermaid state-graph SVGs | β (pre-generated per scenario) | β (no state machine) | N/A β our env doesn't have a state graph | | |
| | Traces tab | β (stored episode JSON replays) | β | Could add if episode traces are stored | | |
| | 6 tabs | β | 5 tabs | Missing "Traces" (requires stored traces) | | |
| | Leaderboard from log files | β (parses output logs) | Static data | Fine for hackathon β logs not generated yet | | |
| | Component-level CSS overrides | β (dropdowns, buttons styled) | Partial | Added in fixed version | | |
| | `pg-row` layout class | β (explicit flex row CSS) | β | Added in fixed version | | |
| | Font: Inter + JetBrains Mono | β | β (via CSS font-family) | Same | | |
| | HF Spaces app_port | β | β | Same | | |
| | Mount at `/` | β | β (fixed) | Same | | |
| --- | |
| ## What is NOT Needed | |
| - **Mermaid diagrams**: Our environment uses a tool-based audit workflow, not a state | |
| machine. Adding fake state graph SVGs would be misleading and add no value. | |
| - **Traces tab**: The reference pre-generates agent traces offline and ships them in | |
| the Docker image. We don't have stored traces yet β the Playground tab covers | |
| interactive exploration. | |
| - **JSONL scenario database**: The reference stores 8 scenarios in `incidents_v3.jsonl`. | |
| Our ground truth is in `data/ground_truth_cases.json` β already structured correctly. | |