@gradio/utils
Advanced tools
Comparing version 0.3.2 to 0.4.0
# @gradio/utils | ||
## 0.4.0 | ||
### Highlights | ||
#### Setting File Upload Limits ([#7909](https://github.com/gradio-app/gradio/pull/7909) [`2afca65`](https://github.com/gradio-app/gradio/commit/2afca6541912b37dc84f447c7ad4af21607d7c72)) | ||
We have added a `max_file_size` size parameter to `launch()` that limits to size of files uploaded to the server. This limit applies to each individual file. This parameter can be specified as a string or an integer (corresponding to the size in bytes). | ||
The following code snippet sets a max file size of 5 megabytes. | ||
```python | ||
import gradio as gr | ||
demo = gr.Interface(lambda x: x, "image", "image") | ||
demo.launch(max_file_size="5mb") | ||
# or | ||
demo.launch(max_file_size=5 * gr.FileSize.MB) | ||
``` | ||
![max_file_size_upload](https://github.com/gradio-app/gradio/assets/41651716/7547330c-a082-4901-a291-3f150a197e45) | ||
#### Error states can now be cleared | ||
When a component encounters an error, the error state shown in the UI can now be cleared by clicking on the `x` icon in the top right of the component. This applies to all types of errors, whether it's raised in the UI or the server. | ||
![error_modal_calculator](https://github.com/gradio-app/gradio/assets/41651716/16cb071c-accd-45a6-9c18-0dea27d4bd98) | ||
Thanks @freddyaboulton! | ||
## 0.3.2 | ||
@@ -4,0 +35,0 @@ |
{ | ||
"name": "@gradio/utils", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "Gradio UI packages", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -183,2 +183,3 @@ import type { ActionReturn } from "svelte/action"; | ||
autoscroll: boolean; | ||
max_file_size: number | null; | ||
@@ -191,3 +192,5 @@ constructor( | ||
root: string, | ||
autoscroll: boolean | ||
autoscroll: boolean, | ||
max_file_size: number | null, | ||
i18n: I18nFormatter = (x: string): string => x | ||
) { | ||
@@ -198,4 +201,5 @@ this.#id = id; | ||
this.#el = el; | ||
this.max_file_size = max_file_size; | ||
this.i18n = (x: string): string => x; | ||
this.i18n = i18n; | ||
this.root = root; | ||
@@ -202,0 +206,0 @@ this.autoscroll = autoscroll; |
22969
189