File size: 6,270 Bytes
abb7e9b
 
f206f49
abb7e9b
 
 
7920e92
 
abb7e9b
 
 
 
 
 
 
 
 
7920e92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb7e9b
 
 
 
f206f49
 
 
 
 
abb7e9b
 
 
 
 
f206f49
abb7e9b
f206f49
abb7e9b
f206f49
abb7e9b
 
 
 
 
 
adb7865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb7e9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f206f49
 
abb7e9b
 
f206f49
 
 
 
abb7e9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f206f49
abb7e9b
 
 
 
 
 
 
 
 
 
 
 
 
f206f49
abb7e9b
 
 
 
 
 
 
 
 
f206f49
 
 
 
 
 
abb7e9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adb7865
abb7e9b
 
adb7865
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# SPEC-23: Gradio 6.0 Modernization Audit

**Status:** IMPLEMENTED
**Priority:** P3 (Technical alignment)
**Effort:** 30 minutes
**Dependencies:** SPEC-22 (Progress Bar Removal)
**Gradio Version:** 6.0.1 (December 2025)
**Last Verified:** 2025-12-07

---

## Executive Summary

Audit of `src/app.py` against Gradio 6.0.1 best practices. Identifies parameters we should add or update for full alignment with modern Gradio.

---

## Gradio Architecture Clarification

### The Three High-Level Classes

| Class | Purpose | Flexibility | Use Case |
|-------|---------|-------------|----------|
| `gr.Blocks` | Low-level building blocks | Most flexible | Custom layouts, multiple components |
| `gr.Interface` | Input β†’ Output wrapper | Medium | ML models, transformations |
| `gr.ChatInterface` | Chat app wrapper | Opinionated | **Chatbots (what we use)** |

### Inheritance Hierarchy

```
gr.Blocks (base)
    ↑
gr.ChatInterface (inherits from Blocks, adds chat-specific features)
```

**Key insight:** `ChatInterface` IS a `Blocks` context internally. We're not mixing different things - we're using the right abstraction for a chat app.

### What ChatInterface Gives Us (For Free)

- Chat history state management
- Submit/Stop buttons
- Streaming support
- Example handling
- `additional_inputs` accordion
- MCP server support (`mcp_server=True`)

### When Would We Need Pure `gr.Blocks`?

Only if we needed:
- Multiple independent chat windows
- Complex multi-panel layouts
- Non-chat components as primary UI

**Verdict:** `ChatInterface` is the correct choice for DeepBoner.

---

## Current State vs Best Practices

| Feature | Current | Best Practice | Action |
|---------|---------|---------------|--------|
| Message format | N/A | OpenAI-style dicts | βœ… **DEFAULT** - Gradio 6.0.1 uses messages format by default |
| `fill_height` | ~~Not set~~ | `fill_height=True` | βœ… **DONE** - Chat fills vertical space |
| `autoscroll` | ~~Not set~~ | `autoscroll=True` | βœ… **DONE** - Auto-scroll to latest message |
| `show_progress` | ~~Not set (minimal)~~ | `show_progress="full"` | βœ… **DONE** - Per SPEC-22 |
| `gr.Progress` | ~~Used (broken)~~ | Remove | βœ… **DONE** - Per SPEC-22 |

---

## Detailed Findings

### 1. Message Format (OpenAI-style)

**Status:** βœ… Default in Gradio 6.0.1

Gradio 6.0.1 uses OpenAI-style dictionaries by default:
```python
{"role": "user" | "assistant", "content": str}
```

This is the modern standard and aligns with our LLM backends.

#### ⚠️ Version-Specific Note: No `type=` Parameter in 6.0.1

**Why online docs may confuse you:**
- Gradio 4.x/5.x had `type="messages"` or `type="tuples"` parameter
- Gradio 6.0.0 **removed** the tuples format entirely ([changelog](https://www.gradio.app/changelog))
- In 6.0.1, there is **no `type` parameter** - messages format is the only format

**Source verification (December 2025):**
```bash
# Check installed signature - no 'type' param exists
uv run python -c "import gradio; import inspect; print([p for p in inspect.signature(gradio.ChatInterface).parameters])"
# Result: ['fn', 'multimodal', 'chatbot', ... ] - no 'type'
```

If you see docs mentioning `type="messages"`, they're from older Gradio versions.

### 2. Fill Height (`fill_height=True`)

**Current:** Not set
**Recommended:** `fill_height=True`

Makes the chat interface fill available vertical space. Better UX on larger screens.

**Known Issue:** [GitHub #10407](https://github.com/gradio-app/gradio/issues/10407) - May conflict with `save_history=True`. We don't use `save_history`, so should be fine.

### 3. Autoscroll (`autoscroll=True`)

**Current:** Not set
**Recommended:** `autoscroll=True`

Ensures chat auto-scrolls to the latest message during streaming. Critical for long research outputs.

---

## Implementation Checklist

### SPEC-22 Items (Do First)
- [x] Remove `progress: gr.Progress = gr.Progress()` from `research_agent` signature
- [x] Remove all `progress(...)` calls in `research_agent`

### SPEC-23 Items
- [x] Add `show_progress="full"` to `gr.ChatInterface`
- [x] Add `fill_height=True` to `gr.ChatInterface`
- [x] Add `autoscroll=True` to `gr.ChatInterface`
- [x] Verify messages format is default (Gradio 6.0.1 - no `type=` param needed)

---

## Code Changes

### Before (Current)
```python
demo = gr.ChatInterface(
    fn=research_agent,
    title="πŸ† DeepBoner",
    description=description,
    examples=[...],
    cache_examples=False,
    run_examples_on_click=False,
    additional_inputs_accordion=additional_inputs_accordion,
    additional_inputs=[...],
)
```

### After (Modernized) βœ… IMPLEMENTED
```python
demo = gr.ChatInterface(
    fn=research_agent,
    title="πŸ† DeepBoner",
    description=description,
    examples=[...],
    cache_examples=False,
    run_examples_on_click=False,
    additional_inputs_accordion=additional_inputs_accordion,
    additional_inputs=[...],
    # SPEC-22: Use native progress instead of gr.Progress
    show_progress="full",
    # SPEC-23: Modern Gradio 6.0 settings
    # NOTE: Gradio 6.0.1 uses messages format by default (no type= param needed)
    fill_height=True,
    autoscroll=True,
)
```

---

## Risk Assessment

| Change | Risk | Status |
|--------|------|--------|
| `show_progress="full"` | Low | βœ… Implemented |
| `fill_height=True` | Low | βœ… Implemented |
| `autoscroll=True` | Low | βœ… Implemented |
| Messages format | None | βœ… Default in Gradio 6.0.1 - no code change needed |

---

## Verification

```bash
# After changes
make check

# Manual test
uv run python src/app.py
# Verify:
# 1. Chat fills vertical space
# 2. Auto-scrolls during streaming
# 3. Spinner appears (not floating progress bar)
```

---

## References

- [Gradio ChatInterface Docs](https://www.gradio.app/docs/gradio/chatinterface)
- [Gradio 6.0 Changelog](https://www.gradio.app/changelog) - Confirms tuples format removal
- [GitHub #10407: fill_height with save_history](https://github.com/gradio-app/gradio/issues/10407)
- [GitHub #11109: Autoscroll issue](https://github.com/gradio-app/gradio/issues/11109)

---

## Version History

| Date | Change |
|------|--------|
| 2025-12-07 | Initial implementation (SPEC-22 + SPEC-23) |
| 2025-12-07 | Added clarification: no `type=` param in Gradio 6.0.1 (tuples removed) |