text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 189
values | source_page_title stringclasses 189
values |
|---|---|---|---|
Shortcuts
gradio.JSON
Interface String Shortcut `"json"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/json | Gradio - Json Docs |
zip_to_jsonblocks_xray
| Demos | https://gradio.app/docs/gradio/json | Gradio - Json Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The JSON component supports the following e... | Event Listeners | https://gradio.app/docs/gradio/json | Gradio - Json Docs |
PI docs. Can be a string or None. If
set to a string, the endpoint will be exposed in the API docs with the given
name. If None (default), the name of the function will be used as the API
endpoint.
api_description: str | None | Literal[False]
default `= None`
Description of the API endpoint. Can be a ... | Event Listeners | https://gradio.app/docs/gradio/json | Gradio - Json Docs |
he function is then
*required* to return a tuple of lists (even if there is only 1 output
component), with each list in the tuple corresponding to one output component.
max_batch_size: int
default `= 4`
Maximum number of inputs to batch together if this is called from the queue
(only relevant if batch... | Event Listeners | https://gradio.app/docs/gradio/json | Gradio - Json Docs |
output components.
concurrency_limit: int | None | Literal['default']
default `= "default"`
If set, this is the maximum number of this event that can be running
simultaneously. Can be set to None to mean no concurrency_limit (any number of
this event can be running simultaneously). Set to "default" t... | Event Listeners | https://gradio.app/docs/gradio/json | Gradio - Json Docs |
ould return a
`gr.validate()` for each input value.
| Event Listeners | https://gradio.app/docs/gradio/json | Gradio - Json Docs |
A Gradio Interface includes a ‘Flag’ button that appears underneath the
output. By default, clicking on the Flag button sends the input and output
data back to the machine where the gradio demo is running, and saves it to a
CSV log file. But this default behavior can be changed. To set what happens
when the Flag button... | Description | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
A simplified implementation of the FlaggingCallback abstract class provided
for illustrative purposes. Each flagged sample (both the input and output
data) is logged to a CSV file on the machine running the gradio app.
| Description | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
import gradio as gr
def image_classifier(inp):
return {'cat': 0.3, 'dog': 0.7}
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label",
flagging_callback=SimpleCSVLogger())
CSVLogger
gradio.CSVLogger(···)
| Example Usage | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
The default implementation of the FlaggingCallback abstract class in
gradio>=5.0. Each flagged sample (both the input and output data) is logged to
a CSV file with headers on the machine running the gradio app. Unlike
ClassicCSVLogger, this implementation is concurrent-safe and it creates a new
dataset file every time ... | Description | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
import gradio as gr
def image_classifier(inp):
return {'cat': 0.3, 'dog': 0.7}
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label",
flagging_callback=CSVLogger())
| Example Usage | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
Parameters ▼
simplify_file_data: bool
default `= True`
If True, the file data will be simplified before being written to the CSV
file. If CSVLogger is being used to cache examples, this is set to False to
preserve the original FileData class
verbose: bool
default `= True`
If True, pr... | Initialization | https://gradio.app/docs/gradio/flagging | Gradio - Flagging Docs |
Blocks is Gradio's low-level API that allows you to create more custom web
applications and demos than Interfaces (yet still entirely in Python).
Compared to the Interface class, Blocks offers more flexibility and control
over: (1) the layout of components (2) the events that trigger the execution
of functions (3)... | Description | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
import gradio as gr
def update(name):
return f"Welcome to Gradio, {name}!"
with gr.Blocks() as demo:
gr.Markdown("Start typing below and then click **Run** to see the output.")
with gr.Row():
inp = gr.Textbox(placeholder="What is your name?")
out = gr.Textbox... | Example Usage | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
Parameters ▼
analytics_enabled: bool | None
default `= None`
Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED
environment variable or default to True.
mode: str
default `= "blocks"`
A human-friendly name for the kind of Blocks or Interface being created. U... | Initialization | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
blocks_helloblocks_flipperblocks_kinematics
| Demos | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
Methods | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs | |
%20Copyright%202022%20Fonticons,%20Inc.... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
-!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%203... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%2039... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
inline: bool | None
default `= None`
whether to display in the gradio app inline in an iframe. Defaults to True in
python notebooks; False otherwise.
inbrowser: bool
default `= False`
whether to automatically launch the gradio app in a new tab on the default
browser.
share: bo... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
default `= False`
If True, any errors in the gradio app will be displayed in an alert modal and
printed in the browser console log. They will also be displayed in the alert
modal of downstream apps that gr.load() this app.
server_name: str | None
default `= None`
to make app accessible on local net... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
t `= False`
If True, suppresses most print statements.
footer_links: list[Literal['api', 'gradio', 'settings'] | dict[str, str]] | None
default `= None`
The links to display in the footer of the app. Accepts a list, where each
element of the list must be one of "api", "gradio", or "settings"
correspo... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ps:// can be
provided, which will be used as the root path in its entirety. Can be set by
environment variable GRADIO_ROOT_PATH. Defaults to "".
app_kwargs: dict[str, Any] | None
default `= None`
Additional keyword arguments to pass to the underlying FastAPI app as a
dictionary of parameter keys and a... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
nsecure.
auth_dependency: Callable[[fastapi.Request], str | None] | None
default `= None`
A function that takes a FastAPI request and returns a string user ID or None.
If the function returns None for a specific request, that user is not
authorized to access the app (they will see a 401 Unauthorized r... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
rendered
using client-side rendering mode. If None, will use GRADIO_SSR_MODE
environment variable or default to False.
pwa: bool | None
default `= None`
If True, the Gradio app will be set up as an installable PWA (Progressive Web
App). If set to None (default behavior), then the PWA feature will be ... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
as a pathlib.Path to a css file or a list of such paths. This css
files will be read, concatenated, and included in the demo webpage. If the
`css` parameter is also set, the css from `css` will be included first.
js: str | Literal[True] | None
default `= None`
Custom js as a code string. The js code ... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%2031... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20318.3L391.3%20319.9C381%203... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
will send status estimations to all clients whenever a job is
finished. Otherwise Queue will send status at regular intervals set by this
parameter as the number of seconds.
api_open: bool | None
default `= None`
If True, the REST routes of the backend will be open, allowing requests made
directly to... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
wandb: ModuleType | None
default `= None`
If the wandb module is provided, will integrate with it and appear on WandB
dashboard
mlflow: ModuleType | None
default `= None`
If the mlflow module is provided, will integrate with the experiment and
appear on ML Flow dashboard
| integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ction function. Each parameter of the function corresponds to one
input component, and the function should return a single value or a tuple of
values, with each element in the tuple corresponding to one output component.
inputs: Component | BlockContext | list[Component | BlockContext] | Set[Component |... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
the runtime display, "hidden"
shows no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list of components to show the progress animation on. If None,
will show the progress animation on all of the output components.
queue: bo... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
s .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
trigger_mode: Literal['once', 'multiple', 'always_last'] | None
default `= None`
If "once" (default for all events except `.change(... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
(hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None
default `= None`
stream_every: float
default `= 0.5`
key: int | str | tuple[int | str, ...] | None
default `= No... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ources. The function should not take any
arguments and the output is not used.
[Blocks And Event Listeners](../../guides/blocks-and-event-
listeners/)[Controlling Layout](../../guides/controlling-layout/)[State In
Blocks](../../guides/state-in-blocks/)[More Blocks
Features](../../guides/more-blocks-features/)
| unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
-!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%203... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%2039... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
inline: bool | None
default `= None`
whether to display in the gradio app inline in an iframe. Defaults to True in
python notebooks; False otherwise.
inbrowser: bool
default `= False`
whether to automatically launch the gradio app in a new tab on the default
browser.
share: bo... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
default `= False`
If True, any errors in the gradio app will be displayed in an alert modal and
printed in the browser console log. They will also be displayed in the alert
modal of downstream apps that gr.load() this app.
server_name: str | None
default `= None`
to make app accessible on local net... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
t `= False`
If True, suppresses most print statements.
footer_links: list[Literal['api', 'gradio', 'settings'] | dict[str, str]] | None
default `= None`
The links to display in the footer of the app. Accepts a list, where each
element of the list must be one of "api", "gradio", or "settings"
correspo... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ps:// can be
provided, which will be used as the root path in its entirety. Can be set by
environment variable GRADIO_ROOT_PATH. Defaults to "".
app_kwargs: dict[str, Any] | None
default `= None`
Additional keyword arguments to pass to the underlying FastAPI app as a
dictionary of parameter keys and a... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
nsecure.
auth_dependency: Callable[[fastapi.Request], str | None] | None
default `= None`
A function that takes a FastAPI request and returns a string user ID or None.
If the function returns None for a specific request, that user is not
authorized to access the app (they will see a 401 Unauthorized r... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
rendered
using client-side rendering mode. If None, will use GRADIO_SSR_MODE
environment variable or default to False.
pwa: bool | None
default `= None`
If True, the Gradio app will be set up as an installable PWA (Progressive Web
App). If set to None (default behavior), then the PWA feature will be ... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
as a pathlib.Path to a css file or a list of such paths. This css
files will be read, concatenated, and included in the demo webpage. If the
`css` parameter is also set, the css from `css` will be included first.
js: str | Literal[True] | None
default `= None`
Custom js as a code string. The js code ... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%2031... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20318.3L391.3%20319.9C381%203... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
will send status estimations to all clients whenever a job is
finished. Otherwise Queue will send status at regular intervals set by this
parameter as the number of seconds.
api_open: bool | None
default `= None`
If True, the REST routes of the backend will be open, allowing requests made
directly to... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
wandb: ModuleType | None
default `= None`
If the wandb module is provided, will integrate with it and appear on WandB
dashboard
mlflow: ModuleType | None
default `= None`
If the mlflow module is provided, will integrate with the experiment and
appear on ML Flow dashboard
| integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ction function. Each parameter of the function corresponds to one
input component, and the function should return a single value or a tuple of
values, with each element in the tuple corresponding to one output component.
inputs: Component | BlockContext | list[Component | BlockContext] | Set[Component |... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
the runtime display, "hidden"
shows no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list of components to show the progress animation on. If None,
will show the progress animation on all of the output components.
queue: bo... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
s .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
trigger_mode: Literal['once', 'multiple', 'always_last'] | None
default `= None`
If "once" (default for all events except `.change(... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
(hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None
default `= None`
stream_every: float
default `= 0.5`
key: int | str | tuple[int | str, ...] | None
default `= No... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ources. The function should not take any
arguments and the output is not used.
| unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
Creates a textarea for users to enter string input or display string output
and also allows for the uploading of multimedia files.
| Description | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
**Using MultimodalTextbox as an input component.**
How MultimodalTextbox will pass its value to your function:
Type: `MultimodalValue | None`
Passes text value and list of file(s) as a `dict` into the function.
Example Code
import gradio as gr
def predict(
value:... | Behavior | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
Parameters ▼
value: str | dict[str, str | list] | Callable | None
default `= None`
Default value to show in MultimodalTextbox. A string value, or a dictionary of
the form {"text": "sample text", "files": [{path: "files/file.jpg", orig_name:
"file.jpg", url: "http://image_url.jpg", size: 100}]}. If a f... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
e`
the label for this component, displayed above the component if `show_label` is
`True` and is also used as the header if there are a table of examples for
this component. If None and used in a `gr.Interface`, the label will be the
name of the parameter this component corresponds to.
info: str | I18nD... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
ected first.
interactive: bool | None
default `= None`
if True, will be rendered as an editable textbox; if False, editing will be
disabled. If not provided, this is inferred based on whether the component is
used as an input or output.
visible: bool | Literal['hidden']
default `= Tru... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
erved_by_key: list[str] | str | None
default `= "value"`
A list of parameters from this component's constructor. Inside a gr.render()
function, if a component is re-rendered with the same key, these (and only
these) parameters will be preserved in the UI (if they have been changed by
the user or an event listener) in... | Initialization | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
Shortcuts
gradio.MultimodalTextbox
Interface String Shortcut `"multimodaltextbox"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
chatbot_multimodal
| Demos | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The MultimodalTextbox component supports th... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
d of the media playing
in the MultimodalTextbox.
Event Parameters
Parameters ▼
fn: Callable | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. Each parameter of the function corresponds to one... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
ss: Literal['full', 'minimal', 'hidden']
default `= "full"`
how to show the progress animation while event is running: "full" shows a
spinner which covers the output component area as well as a runtime display in
the upper right corner, "minimal" only shows the runtime display, "hidden"
shows no progress animation at... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
dict[str, Any] | list[dict[str, Any]] | None
default `= None`
A list of other events to cancel when this listener is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generat... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
'undocumented']
default `= "public"`
controls the visibility and accessibility of this endpoint. Can be "public"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.loa... | Event Listeners | https://gradio.app/docs/gradio/multimodaltextbox | Gradio - Multimodaltextbox Docs |
The FileData class is a subclass of the GradioModel class that represents a
file object within a Gradio interface. It is used to store file data and
metadata when a file is uploaded.
| Description | https://gradio.app/docs/gradio/filedata | Gradio - Filedata Docs |
from gradio_client import Client, FileData, handle_file
def get_url_on_server(data: FileData):
print(data['url'])
client = Client("gradio/gif_maker_main", download_files=False)
job = client.submit([handle_file("./cheetah.jpg")], api_name="/predict")
data = job.result()
video: FileD... | Example Usage | https://gradio.app/docs/gradio/filedata | Gradio - Filedata Docs |
Parameters ▼
path: str
The server file path where the file is stored.
url: Optional[str]
The normalized server URL pointing to the file.
size: Optional[int]
The size of the file in bytes.
orig_name: Optional[str]
The original filename before upload.
... | Attributes | https://gradio.app/docs/gradio/filedata | Gradio - Filedata Docs |
Decorator that auto-caches function results based on content-hashed inputs.
Works with sync/async functions and sync/async generators. For generators, all
yielded values are cached and replayed on hit. Cache hits bypass the Gradio
queue. It can also be called at runtime as `gr.cache(fn)(*args)` to cache
intermediate he... | Description | https://gradio.app/docs/gradio/cache | Gradio - Cache Docs |
import gradio as gr
@gr.cache
def classify(image):
return model.predict(image)
@gr.cache(max_size=256, per_session=True)
def generate(prompt):
return llm(prompt)
| Example Usage | https://gradio.app/docs/gradio/cache | Gradio - Cache Docs |
Parameters ▼
fn: Callable | None
default `= None`
The function to cache. When used as @gr.cache without parentheses, this is the
decorated function. When used as @gr.cache(...), this is None. When used as
`gr.cache(fn)(...)`, this must be a callable.
key: Callable | None
default `= No... | Initialization | https://gradio.app/docs/gradio/cache | Gradio - Cache Docs |
This function allows you to pass custom warning messages to the user. You
can do so simply by writing `gr.Warning('message here')` in your function, and
when that line is executed the custom message will appear in a modal on the
demo. The modal is yellow by default and has the heading: "Warning." Queue
must be enabled ... | Description | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
import gradio as gr
def hello_world():
gr.Warning('This is a warning message.')
return "hello world"
with gr.Blocks() as demo:
md = gr.Markdown()
demo.load(hello_world, inputs=None, outputs=[md])
demo.queue().launch()
| Example Usage | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
Parameters ▼
message: str
default `= "Warning issued."`
The warning message to be displayed to the user. Can be HTML, which will be
rendered in the modal.
duration: float | None
default `= 10`
The duration in seconds that the warning message should be displayed for. If
None or 0, the... | Initialization | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
blocks_chained_events
[Alerts](../../guides/alerts)
| Demos | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
Creates a chatbot that displays user-submitted messages and responses.
Supports a subset of Markdown including bold, italics, code, tables. Also
supports audio/video/image files, which are displayed in the Chatbot, and
other kinds of files which are displayed as links. This component is usually
used as an output compon... | Description | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
The Chatbot component accepts a list of messages, where each message is a
dictionary with `role` and `content` keys. This format is compatible with the
message format expected by most LLM APIs (OpenAI, Claude, HuggingChat, etc.),
making it easy to pipe model outputs directly into the component.
The `role` key should b... | Behavior | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
Parameters ▼
value: list[MessageDict | Message] | Callable | None
default `= None`
Default list of messages to show in chatbot, where each message is of the
format {"role": "user", "content": "Help me."}. Role can be one of "user",
"assistant", or "system". Content should be either text, or media pass... | Initialization | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
wide
as B. Should be an integer. scale applies in Rows, and to top-level Components
in Blocks where fill_height=True.
min_width: int
default `= 160`
minimum pixel width, will wrap if not sufficient screen space to satisfy this
value. If a certain scale value results in this Component being narrower th... | Initialization | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
parameters from this component's constructor. Inside a gr.render()
function, if a component is re-rendered with the same key, these (and only
these) parameters will be preserved in the UI (if they have been changed by
the user or an event listener) instead of re-rendered based on the values
provided during constructor... | Initialization | https://gradio.app/docs/gradio/chatbot | Gradio - Chatbot Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.