Update migration_guide.txt
Browse files- migration_guide.txt +66 -0
migration_guide.txt
CHANGED
|
@@ -1,5 +1,11 @@
|
|
| 1 |
# Gradio 6 Migration Guide
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## App-level Changes
|
| 4 |
|
| 5 |
### App-level parameters have been moved from `Blocks` to `launch()`
|
|
@@ -312,6 +318,50 @@ history = [
|
|
| 312 |
|
| 313 |
This structured format allows for multimodal content (text, images, files, etc.) in chat messages, making it consistent with OpenAI's API format. All files uploaded in a single message are grouped together in the `content` array along with any text content.
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
## Component-level Changes
|
| 316 |
|
| 317 |
### `gr.Video` no longer accepts tuple values for video and subtitles
|
|
@@ -503,6 +553,7 @@ chatbot = gr.Chatbot(allow_tags=["thinking", "tool_call"])
|
|
| 503 |
This will only preserve `<thinking>` and `<tool_call>` tags while removing all other custom tags.
|
| 504 |
|
| 505 |
|
|
|
|
| 506 |
### Other removed component parameters
|
| 507 |
|
| 508 |
Several component parameters have been removed in Gradio 6.0. These parameters were previously deprecated and have now been fully removed.
|
|
@@ -803,6 +854,21 @@ slider = gr.Slider(show_reset_button=True)
|
|
| 803 |
slider = gr.Slider(buttons=["reset"])
|
| 804 |
```
|
| 805 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
## Python Client Changes
|
| 807 |
|
| 808 |
### `hf_token` parameter renamed to `token` in `Client`
|
|
|
|
| 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. This migration guide lists the breaking changes and the specific code changes needed in order to migrate. The easiest way to know whether you need to make changes is to upgrade your Gradio app to 5.50 (`pip install --upgrade gradio==5.50`). Gradio 5.50 emits deprecation warnings for any parameters removed in Gradio 6, allowing you to know whether your Gradio app will be compatible with Gradio 6.
|
| 6 |
+
|
| 7 |
+
Here, we walk through the breaking changes that were introduced in Gradio 6. Code snippets are provided, allowing you to migrate your code easily to Gradio 6. You can also copy-paste this document as Markdown if you are using an LLM to help migrate your code.
|
| 8 |
+
|
| 9 |
## App-level Changes
|
| 10 |
|
| 11 |
### App-level parameters have been moved from `Blocks` to `launch()`
|
|
|
|
| 318 |
|
| 319 |
This structured format allows for multimodal content (text, images, files, etc.) in chat messages, making it consistent with OpenAI's API format. All files uploaded in a single message are grouped together in the `content` array along with any text content.
|
| 320 |
|
| 321 |
+
### `cache_examples` parameter updated and `cache_mode` introduced
|
| 322 |
+
|
| 323 |
+
The `cache_examples` parameter (used in `Interface`, `ChatInterface`, and `Examples`) no longer accepts the string value `"lazy"`. It now strictly accepts boolean values (`True` or `False`). To control the caching strategy, a new `cache_mode` parameter has been introduced.
|
| 324 |
+
|
| 325 |
+
**In Gradio 5.x:**
|
| 326 |
+
- `cache_examples` accepted `True`, `False`, or `"lazy"`.
|
| 327 |
+
|
| 328 |
+
**In Gradio 6.x:**
|
| 329 |
+
- `cache_examples` only accepts `True` or `False`.
|
| 330 |
+
- `cache_mode` accepts `"eager"` (default) or `"lazy"`.
|
| 331 |
+
|
| 332 |
+
**Before (Gradio 5.x):**
|
| 333 |
+
|
| 334 |
+
```python
|
| 335 |
+
import gradio as gr
|
| 336 |
+
|
| 337 |
+
demo = gr.Interface(
|
| 338 |
+
fn=predict,
|
| 339 |
+
inputs="text",
|
| 340 |
+
outputs="text",
|
| 341 |
+
examples=["Hello", "World"],
|
| 342 |
+
cache_examples="lazy"
|
| 343 |
+
)
|
| 344 |
+
```
|
| 345 |
+
|
| 346 |
+
**After (Gradio 6.x):**
|
| 347 |
+
|
| 348 |
+
You must now set `cache_examples=True` and specify the mode separately:
|
| 349 |
+
|
| 350 |
+
```python
|
| 351 |
+
import gradio as gr
|
| 352 |
+
|
| 353 |
+
demo = gr.Interface(
|
| 354 |
+
fn=predict,
|
| 355 |
+
inputs="text",
|
| 356 |
+
outputs="text",
|
| 357 |
+
examples=["Hello", "World"],
|
| 358 |
+
cache_examples=True,
|
| 359 |
+
cache_mode="lazy"
|
| 360 |
+
)
|
| 361 |
+
```
|
| 362 |
+
|
| 363 |
+
If you previously used `cache_examples=True` (which implied eager caching), no changes are required, as `cache_mode` defaults to `"eager"`.
|
| 364 |
+
|
| 365 |
## Component-level Changes
|
| 366 |
|
| 367 |
### `gr.Video` no longer accepts tuple values for video and subtitles
|
|
|
|
| 553 |
This will only preserve `<thinking>` and `<tool_call>` tags while removing all other custom tags.
|
| 554 |
|
| 555 |
|
| 556 |
+
|
| 557 |
### Other removed component parameters
|
| 558 |
|
| 559 |
Several component parameters have been removed in Gradio 6.0. These parameters were previously deprecated and have now been fully removed.
|
|
|
|
| 854 |
slider = gr.Slider(buttons=["reset"])
|
| 855 |
```
|
| 856 |
|
| 857 |
+
|
| 858 |
+
## CLI Changes
|
| 859 |
+
|
| 860 |
+
### `gradio sketch` command removed
|
| 861 |
+
|
| 862 |
+
The `gradio sketch` command-line tool has been deprecated and completely removed in Gradio 6. This tool was used to create Gradio apps through a visual interface.
|
| 863 |
+
|
| 864 |
+
**In Gradio 5.x:**
|
| 865 |
+
- You could run `gradio sketch` to launch an interactive GUI for building Gradio apps
|
| 866 |
+
- The tool would generate Python code visually
|
| 867 |
+
|
| 868 |
+
**In Gradio 6.x:**
|
| 869 |
+
- The `gradio sketch` command has been removed
|
| 870 |
+
- Running `gradio sketch` will raise a `DeprecationWarning`
|
| 871 |
+
|
| 872 |
## Python Client Changes
|
| 873 |
|
| 874 |
### `hf_token` parameter renamed to `token` in `Client`
|