multimodalart HF Staff commited on
Commit
0c5f6d7
·
verified ·
1 Parent(s): 02d2af6

Create migration_guide.txt

Browse files
Files changed (1) hide show
  1. migration_guide.txt +163 -0
migration_guide.txt ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gradio 6 Migration Guide
2
+
3
+ We are excited to release Gradio 6, the latest major version of the Gradio library. Gradio 6 is significantly more performant, lighter, and easier to customize than previous versions of Gradio. The Gradio team is only planning on maintaining future versions of Gradio 6 so we encourage all developers to migrate to Gradio 6.x.
4
+
5
+ Gradio 6 includes several breaking changes that were made in order to standardize the Python API.
6
+
7
+ ## App-level Changes
8
+
9
+ ### App-level parameters have been moved from `Blocks` to `launch()`
10
+
11
+ The `gr.Blocks` class constructor previously contained several parameters that applied to your entire Gradio app (theme, css, js, head). Since `gr.Blocks` can be nested, these have moved to `launch()`.
12
+
13
+ **Before (Gradio 5.x):**
14
+ ```python
15
+ with gr.Blocks(theme=gr.themes.Soft(), css=".my-class { color: red; }") as demo:
16
+ ...
17
+ demo.launch()
18
+ ```
19
+
20
+ **After (Gradio 6.x):**
21
+ ```python
22
+ with gr.Blocks() as demo:
23
+ ...
24
+ demo.launch(theme=gr.themes.Soft(), css=".my-class { color: red; }")
25
+ ```
26
+
27
+ ### `show_api` parameter replaced with `footer_links`
28
+
29
+ **Before (Gradio 5.x):**
30
+ - `demo.launch(show_api=False)`
31
+
32
+ **After (Gradio 6.x):**
33
+ - `demo.launch(footer_links=["gradio", "settings"])`
34
+ - To show API: `demo.launch(footer_links=["api", "gradio", "settings"])` (or default)
35
+
36
+ ### Event listener parameters: `show_api` removed and `api_name=False` no longer supported
37
+
38
+ **Before (Gradio 5.x):**
39
+ ```python
40
+ btn.click(fn=..., show_api=False)
41
+ # OR
42
+ btn.click(fn=..., api_name=False)
43
+ ```
44
+
45
+ **After (Gradio 6.x):**
46
+ ```python
47
+ # Equivalent to show_api=False
48
+ btn.click(fn=..., api_visibility="undocumented")
49
+
50
+ # Equivalent to api_name=False
51
+ btn.click(fn=..., api_visibility="private")
52
+
53
+ # Default is api_visibility="public"
54
+ ```
55
+
56
+ ### `like_user_message` moved from `.like()` event to constructor
57
+
58
+ **Before (Gradio 5.x):**
59
+ ```python
60
+ chatbot.like(print_like_dislike, None, None, like_user_message=True)
61
+ ```
62
+
63
+ **After (Gradio 6.x):**
64
+ ```python
65
+ chatbot = gr.Chatbot(like_user_message=True)
66
+ chatbot.like(print_like_dislike, None, None)
67
+ ```
68
+
69
+ ### Default API names for `Interface` and `ChatInterface` now use function names
70
+
71
+ **Before:** `gr.Interface(fn=predict)` generated endpoint `/predict`.
72
+ **After:** `gr.Interface(fn=predict)` generates endpoint `/predict` (the function name).
73
+ To keep old names: `gr.Interface(..., api_name="predict")`.
74
+
75
+ ### `gr.Chatbot` and `gr.ChatInterface` tuple format removed
76
+
77
+ **Before (Gradio 5.x):**
78
+ ```python
79
+ chatbot = gr.Chatbot(value=[["User message", "Bot message"]])
80
+ ```
81
+
82
+ **After (Gradio 6.x):**
83
+ ```python
84
+ chatbot = gr.Chatbot(
85
+ value=[
86
+ {"role": "user", "content": "User message"},
87
+ {"role": "assistant", "content": "Bot message"}
88
+ ],
89
+ type="messages"
90
+ )
91
+ ```
92
+
93
+ ### `gr.ChatInterface` `history` format now uses structured content
94
+
95
+ Content is now always a list of content blocks, even for text.
96
+
97
+ **Before:** `{"role": "user", "content": "Hello"}`
98
+ **After:** `{"role": "user", "content": [{"type": "text", "text": "Hello"}]}`
99
+
100
+ ## Component-level Changes
101
+
102
+ ### `gr.Video` no longer accepts tuple values for video and subtitles
103
+
104
+ **Before (Gradio 5.x):**
105
+ ```python
106
+ return ("video.mp4", "subs.srt")
107
+ ```
108
+
109
+ **After (Gradio 6.x):**
110
+ ```python
111
+ return gr.Video(value="video.mp4", subtitles="subs.srt")
112
+ ```
113
+
114
+ ### `gr.HTML` `padding` parameter default changed to `False`
115
+
116
+ **After (Gradio 6.x):** Default is `padding=False`. Use `padding=True` explicitly to match old behavior.
117
+
118
+ ### `gr.Dataframe` `row_count` and `col_count` parameters restructured
119
+
120
+ **Before:** `row_count=(5, "fixed")`
121
+ **After:** `row_count=5, row_limits=(5, 5)`
122
+
123
+ **Before:** `row_count=(5, "dynamic")`
124
+ **After:** `row_count=5, row_limits=None`
125
+
126
+ ### `allow_tags=True` is now the default for `gr.Chatbot`
127
+
128
+ **After (Gradio 6.x):** Tags are allowed by default. To sanitize, use `allow_tags=False`.
129
+
130
+ ### Removed Component Parameters
131
+
132
+ #### `gr.Chatbot`
133
+ - `bubble_full_width` removed.
134
+ - `show_copy_button` -> use `buttons=["copy"]`.
135
+ - `show_share_button` -> use `buttons=["share"]`.
136
+
137
+ #### `gr.Audio` / `gr.Video` / `gr.Image`
138
+ - `show_download_button` -> use `buttons=["download"]`.
139
+ - `show_share_button` -> use `buttons=["share"]`.
140
+ - `min_length` / `max_length` -> use `validator=...`.
141
+ - `mirror_webcam` -> use `webcam_options=gr.WebcamOptions(mirror=True)`.
142
+
143
+ #### `gr.ImageEditor`
144
+ - `crop_size` -> use `canvas_size`.
145
+
146
+ #### `gr.LogoutButton`
147
+ - Removed. Use `gr.LoginButton`.
148
+
149
+ #### Plot Components
150
+ - `show_fullscreen_button` -> `buttons=["fullscreen"]`.
151
+ - `color_legend_title` -> `color_title`.
152
+
153
+ ## Python Client Changes
154
+
155
+ ### `hf_token` parameter renamed to `token` in `Client`
156
+ **Before:** `Client(..., hf_token="...")`
157
+ **After:** `Client(..., token="...")`
158
+
159
+ ### `deploy_discord` method deprecated
160
+ Removed.
161
+
162
+ ### `AppError` now subclasses `Exception`
163
+ Catch `AppError` specifically, not `ValueError`.