VibecoderMcSwaggins commited on
Commit
f206f49
Β·
1 Parent(s): 26fdadb

docs(SPEC-23): Complete Gradio 6.0.1 modernization audit

Browse files

SPEC-23 is now fully implemented:
- show_progress="full" βœ…
- fill_height=True βœ…
- autoscroll=True βœ…
- Messages format βœ… (default in 6.0.1 - no type= param needed)

Key finding: Gradio 6.0.1 uses OpenAI-style message format by
default. The `type="messages"` parameter referenced in some docs
does not exist in 6.0.1 - the legacy tuple format was removed.

Updated SPEC-23 documentation to reflect the actual implementation.

docs/specs/SPEC-23-GRADIO-MODERNIZATION.md CHANGED
@@ -1,6 +1,6 @@
1
  # SPEC-23: Gradio 6.0 Modernization Audit
2
 
3
- **Status:** READY FOR IMPLEMENTATION
4
  **Priority:** P3 (Technical alignment)
5
  **Effort:** 30 minutes
6
  **Dependencies:** SPEC-22 (Progress Bar Removal)
@@ -59,29 +59,28 @@ Only if we needed:
59
 
60
  | Feature | Current | Best Practice | Action |
61
  |---------|---------|---------------|--------|
62
- | `type` param | Not set (legacy) | `type="messages"` | **ADD** - Uses OpenAI-style message format |
63
- | `fill_height` | Not set | `fill_height=True` | **ADD** - Chat fills vertical space |
64
- | `autoscroll` | Not set | `autoscroll=True` | **ADD** - Auto-scroll to latest message |
65
- | `show_progress` | Not set (minimal) | `show_progress="full"` | **ADD** - Per SPEC-22 |
66
- | `gr.Progress` | Used (broken) | Remove | **REMOVE** - Per SPEC-22 |
67
 
68
  ---
69
 
70
  ## Detailed Findings
71
 
72
- ### 1. Message Format (`type="messages"`)
73
 
74
- **Current:** Not specified (uses legacy tuple format)
75
- **Recommended:** `type="messages"`
76
 
77
- The `type="messages"` format uses OpenAI-style dictionaries:
78
  ```python
79
  {"role": "user" | "assistant", "content": str}
80
  ```
81
 
82
  This is the modern standard and aligns with our LLM backends.
83
 
84
- **Note:** This may require updating how we handle `history` parameter.
85
 
86
  ### 2. Fill Height (`fill_height=True`)
87
 
@@ -104,14 +103,14 @@ Ensures chat auto-scrolls to the latest message during streaming. Critical for l
104
  ## Implementation Checklist
105
 
106
  ### SPEC-22 Items (Do First)
107
- - [ ] Remove `progress: gr.Progress = gr.Progress()` from `research_agent` signature
108
- - [ ] Remove all `progress(...)` calls in `research_agent`
109
 
110
  ### SPEC-23 Items
111
- - [ ] Add `show_progress="full"` to `gr.ChatInterface`
112
- - [ ] Add `fill_height=True` to `gr.ChatInterface`
113
- - [ ] Add `autoscroll=True` to `gr.ChatInterface`
114
- - [ ] Evaluate `type="messages"` migration (may require history format changes)
115
 
116
  ---
117
 
@@ -131,7 +130,7 @@ demo = gr.ChatInterface(
131
  )
132
  ```
133
 
134
- ### After (Modernized)
135
  ```python
136
  demo = gr.ChatInterface(
137
  fn=research_agent,
@@ -145,9 +144,9 @@ demo = gr.ChatInterface(
145
  # SPEC-22: Use native progress instead of gr.Progress
146
  show_progress="full",
147
  # SPEC-23: Modern Gradio 6.0 settings
 
148
  fill_height=True,
149
  autoscroll=True,
150
- # NOTE: type="messages" requires history format migration - evaluate separately
151
  )
152
  ```
153
 
@@ -155,12 +154,12 @@ demo = gr.ChatInterface(
155
 
156
  ## Risk Assessment
157
 
158
- | Change | Risk | Mitigation |
159
- |--------|------|------------|
160
- | `show_progress="full"` | Low | Native Gradio feature |
161
- | `fill_height=True` | Low | May affect layout, test visually |
162
- | `autoscroll=True` | Low | Native feature, improves UX |
163
- | `type="messages"` | Medium | Requires history format changes - defer if needed |
164
 
165
  ---
166
 
 
1
  # SPEC-23: Gradio 6.0 Modernization Audit
2
 
3
+ **Status:** IMPLEMENTED
4
  **Priority:** P3 (Technical alignment)
5
  **Effort:** 30 minutes
6
  **Dependencies:** SPEC-22 (Progress Bar Removal)
 
59
 
60
  | Feature | Current | Best Practice | Action |
61
  |---------|---------|---------------|--------|
62
+ | Message format | N/A | OpenAI-style dicts | βœ… **DEFAULT** - Gradio 6.0.1 uses messages format by default |
63
+ | `fill_height` | ~~Not set~~ | `fill_height=True` | βœ… **DONE** - Chat fills vertical space |
64
+ | `autoscroll` | ~~Not set~~ | `autoscroll=True` | βœ… **DONE** - Auto-scroll to latest message |
65
+ | `show_progress` | ~~Not set (minimal)~~ | `show_progress="full"` | βœ… **DONE** - Per SPEC-22 |
66
+ | `gr.Progress` | ~~Used (broken)~~ | Remove | βœ… **DONE** - Per SPEC-22 |
67
 
68
  ---
69
 
70
  ## Detailed Findings
71
 
72
+ ### 1. Message Format (OpenAI-style)
73
 
74
+ **Status:** βœ… Default in Gradio 6.0.1
 
75
 
76
+ Gradio 6.0.1 uses OpenAI-style dictionaries by default:
77
  ```python
78
  {"role": "user" | "assistant", "content": str}
79
  ```
80
 
81
  This is the modern standard and aligns with our LLM backends.
82
 
83
+ **Note:** No `type=` parameter exists in Gradio 6.0.1 - the legacy tuple format was removed.
84
 
85
  ### 2. Fill Height (`fill_height=True`)
86
 
 
103
  ## Implementation Checklist
104
 
105
  ### SPEC-22 Items (Do First)
106
+ - [x] Remove `progress: gr.Progress = gr.Progress()` from `research_agent` signature
107
+ - [x] Remove all `progress(...)` calls in `research_agent`
108
 
109
  ### SPEC-23 Items
110
+ - [x] Add `show_progress="full"` to `gr.ChatInterface`
111
+ - [x] Add `fill_height=True` to `gr.ChatInterface`
112
+ - [x] Add `autoscroll=True` to `gr.ChatInterface`
113
+ - [x] Verify messages format is default (Gradio 6.0.1 - no `type=` param needed)
114
 
115
  ---
116
 
 
130
  )
131
  ```
132
 
133
+ ### After (Modernized) βœ… IMPLEMENTED
134
  ```python
135
  demo = gr.ChatInterface(
136
  fn=research_agent,
 
144
  # SPEC-22: Use native progress instead of gr.Progress
145
  show_progress="full",
146
  # SPEC-23: Modern Gradio 6.0 settings
147
+ # NOTE: Gradio 6.0.1 uses messages format by default (no type= param needed)
148
  fill_height=True,
149
  autoscroll=True,
 
150
  )
151
  ```
152
 
 
154
 
155
  ## Risk Assessment
156
 
157
+ | Change | Risk | Status |
158
+ |--------|------|--------|
159
+ | `show_progress="full"` | Low | βœ… Implemented |
160
+ | `fill_height=True` | Low | βœ… Implemented |
161
+ | `autoscroll=True` | Low | βœ… Implemented |
162
+ | Messages format | None | βœ… Default in Gradio 6.0.1 - no code change needed |
163
 
164
  ---
165
 
src/app.py CHANGED
@@ -141,7 +141,7 @@ async def research_agent(
141
 
142
  Args:
143
  message: User's research question
144
- history: Chat history (Gradio format)
145
  domain: Research domain (None defaults to "sexual_health")
146
  api_key: Optional user-provided API key (BYOK - auto-detects provider)
147
  api_key_state: Persistent API key state (survives example clicks, can be None)
@@ -264,6 +264,7 @@ def create_demo() -> tuple[gr.ChatInterface, gr.Accordion]:
264
  # SPEC-22: Use native progress instead of gr.Progress (which breaks ChatInterface)
265
  show_progress="full",
266
  # SPEC-23: Gradio 6.0 best practices
 
267
  fill_height=True,
268
  autoscroll=True,
269
  examples=[
 
141
 
142
  Args:
143
  message: User's research question
144
+ history: Chat history (OpenAI-style: [{"role": "user"|"assistant", "content": str}])
145
  domain: Research domain (None defaults to "sexual_health")
146
  api_key: Optional user-provided API key (BYOK - auto-detects provider)
147
  api_key_state: Persistent API key state (survives example clicks, can be None)
 
264
  # SPEC-22: Use native progress instead of gr.Progress (which breaks ChatInterface)
265
  show_progress="full",
266
  # SPEC-23: Gradio 6.0 best practices
267
+ # NOTE: Gradio 6.0.1 uses messages format by default (no type= param needed)
268
  fill_height=True,
269
  autoscroll=True,
270
  examples=[