Merge pull request #139 from The-Obstacle-Is-The-Way/feature/spec-23-messages-format
Browse files- docs/specs/SPEC-23-GRADIO-MODERNIZATION.md +48 -25
- src/app.py +2 -1
docs/specs/SPEC-23-GRADIO-MODERNIZATION.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# SPEC-23: Gradio 6.0 Modernization Audit
|
| 2 |
|
| 3 |
-
**Status:**
|
| 4 |
**Priority:** P3 (Technical alignment)
|
| 5 |
**Effort:** 30 minutes
|
| 6 |
**Dependencies:** SPEC-22 (Progress Bar Removal)
|
|
@@ -59,29 +59,42 @@ Only if we needed:
|
|
| 59 |
|
| 60 |
| Feature | Current | Best Practice | Action |
|
| 61 |
|---------|---------|---------------|--------|
|
| 62 |
-
|
|
| 63 |
-
| `fill_height` | Not set | `fill_height=True` | **
|
| 64 |
-
| `autoscroll` | Not set | `autoscroll=True` | **
|
| 65 |
-
| `show_progress` | Not set (minimal) | `show_progress="full"` | **
|
| 66 |
-
| `gr.Progress` | Used (broken) | Remove | **
|
| 67 |
|
| 68 |
---
|
| 69 |
|
| 70 |
## Detailed Findings
|
| 71 |
|
| 72 |
-
### 1. Message Format (
|
| 73 |
|
| 74 |
-
**
|
| 75 |
-
**Recommended:** `type="messages"`
|
| 76 |
|
| 77 |
-
|
| 78 |
```python
|
| 79 |
{"role": "user" | "assistant", "content": str}
|
| 80 |
```
|
| 81 |
|
| 82 |
This is the modern standard and aligns with our LLM backends.
|
| 83 |
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
### 2. Fill Height (`fill_height=True`)
|
| 87 |
|
|
@@ -104,14 +117,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 |
-
- [
|
| 108 |
-
- [
|
| 109 |
|
| 110 |
### SPEC-23 Items
|
| 111 |
-
- [
|
| 112 |
-
- [
|
| 113 |
-
- [
|
| 114 |
-
- [
|
| 115 |
|
| 116 |
---
|
| 117 |
|
|
@@ -131,7 +144,7 @@ demo = gr.ChatInterface(
|
|
| 131 |
)
|
| 132 |
```
|
| 133 |
|
| 134 |
-
### After (Modernized)
|
| 135 |
```python
|
| 136 |
demo = gr.ChatInterface(
|
| 137 |
fn=research_agent,
|
|
@@ -145,9 +158,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 +168,12 @@ demo = gr.ChatInterface(
|
|
| 155 |
|
| 156 |
## Risk Assessment
|
| 157 |
|
| 158 |
-
| Change | Risk |
|
| 159 |
-
|
| 160 |
-
| `show_progress="full"` | Low |
|
| 161 |
-
| `fill_height=True` | Low |
|
| 162 |
-
| `autoscroll=True` | Low |
|
| 163 |
-
|
|
| 164 |
|
| 165 |
---
|
| 166 |
|
|
@@ -183,5 +196,15 @@ uv run python src/app.py
|
|
| 183 |
## References
|
| 184 |
|
| 185 |
- [Gradio ChatInterface Docs](https://www.gradio.app/docs/gradio/chatinterface)
|
|
|
|
| 186 |
- [GitHub #10407: fill_height with save_history](https://github.com/gradio-app/gradio/issues/10407)
|
| 187 |
- [GitHub #11109: Autoscroll issue](https://github.com/gradio-app/gradio/issues/11109)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#### β οΈ Version-Specific Note: No `type=` Parameter in 6.0.1
|
| 84 |
+
|
| 85 |
+
**Why online docs may confuse you:**
|
| 86 |
+
- Gradio 4.x/5.x had `type="messages"` or `type="tuples"` parameter
|
| 87 |
+
- Gradio 6.0.0 **removed** the tuples format entirely ([changelog](https://www.gradio.app/changelog))
|
| 88 |
+
- In 6.0.1, there is **no `type` parameter** - messages format is the only format
|
| 89 |
+
|
| 90 |
+
**Source verification (December 2025):**
|
| 91 |
+
```bash
|
| 92 |
+
# Check installed signature - no 'type' param exists
|
| 93 |
+
uv run python -c "import gradio; import inspect; print([p for p in inspect.signature(gradio.ChatInterface).parameters])"
|
| 94 |
+
# Result: ['fn', 'multimodal', 'chatbot', ... ] - no 'type'
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
If you see docs mentioning `type="messages"`, they're from older Gradio versions.
|
| 98 |
|
| 99 |
### 2. Fill Height (`fill_height=True`)
|
| 100 |
|
|
|
|
| 117 |
## Implementation Checklist
|
| 118 |
|
| 119 |
### SPEC-22 Items (Do First)
|
| 120 |
+
- [x] Remove `progress: gr.Progress = gr.Progress()` from `research_agent` signature
|
| 121 |
+
- [x] Remove all `progress(...)` calls in `research_agent`
|
| 122 |
|
| 123 |
### SPEC-23 Items
|
| 124 |
+
- [x] Add `show_progress="full"` to `gr.ChatInterface`
|
| 125 |
+
- [x] Add `fill_height=True` to `gr.ChatInterface`
|
| 126 |
+
- [x] Add `autoscroll=True` to `gr.ChatInterface`
|
| 127 |
+
- [x] Verify messages format is default (Gradio 6.0.1 - no `type=` param needed)
|
| 128 |
|
| 129 |
---
|
| 130 |
|
|
|
|
| 144 |
)
|
| 145 |
```
|
| 146 |
|
| 147 |
+
### After (Modernized) β
IMPLEMENTED
|
| 148 |
```python
|
| 149 |
demo = gr.ChatInterface(
|
| 150 |
fn=research_agent,
|
|
|
|
| 158 |
# SPEC-22: Use native progress instead of gr.Progress
|
| 159 |
show_progress="full",
|
| 160 |
# SPEC-23: Modern Gradio 6.0 settings
|
| 161 |
+
# NOTE: Gradio 6.0.1 uses messages format by default (no type= param needed)
|
| 162 |
fill_height=True,
|
| 163 |
autoscroll=True,
|
|
|
|
| 164 |
)
|
| 165 |
```
|
| 166 |
|
|
|
|
| 168 |
|
| 169 |
## Risk Assessment
|
| 170 |
|
| 171 |
+
| Change | Risk | Status |
|
| 172 |
+
|--------|------|--------|
|
| 173 |
+
| `show_progress="full"` | Low | β
Implemented |
|
| 174 |
+
| `fill_height=True` | Low | β
Implemented |
|
| 175 |
+
| `autoscroll=True` | Low | β
Implemented |
|
| 176 |
+
| Messages format | None | β
Default in Gradio 6.0.1 - no code change needed |
|
| 177 |
|
| 178 |
---
|
| 179 |
|
|
|
|
| 196 |
## References
|
| 197 |
|
| 198 |
- [Gradio ChatInterface Docs](https://www.gradio.app/docs/gradio/chatinterface)
|
| 199 |
+
- [Gradio 6.0 Changelog](https://www.gradio.app/changelog) - Confirms tuples format removal
|
| 200 |
- [GitHub #10407: fill_height with save_history](https://github.com/gradio-app/gradio/issues/10407)
|
| 201 |
- [GitHub #11109: Autoscroll issue](https://github.com/gradio-app/gradio/issues/11109)
|
| 202 |
+
|
| 203 |
+
---
|
| 204 |
+
|
| 205 |
+
## Version History
|
| 206 |
+
|
| 207 |
+
| Date | Change |
|
| 208 |
+
|------|--------|
|
| 209 |
+
| 2025-12-07 | Initial implementation (SPEC-22 + SPEC-23) |
|
| 210 |
+
| 2025-12-07 | Added clarification: no `type=` param in Gradio 6.0.1 (tuples removed) |
|
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 (
|
| 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=[
|