Skip to content

Commit a4433be

Browse files
Ability to disable orange progress animation for generators (#8543)
* Add code * deletion * add changeset * add changeset * Update nasty-actors-kick.md Update changelog --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent 81ae766 commit a4433be

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

.changeset/nasty-actors-kick.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/statustracker": patch
3+
"gradio": patch
4+
---
5+
6+
fix:Ability to disable orange progress animation for generators by setting `show_progress='minimal'` or `show_progress='hidden'` in the event definition. This is a small visual breaking change but it aligns better with the expected behavior of the `show_progress` parameter. Also added `show_progress` to `gr.Interface` and `gr.ChatInterface`.

gradio/chat_interface.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def __init__(
8080
concurrency_limit: int | None | Literal["default"] = "default",
8181
fill_height: bool = True,
8282
delete_cache: tuple[int, int] | None = None,
83+
show_progress: Literal["full", "minimal", "hidden"] = "minimal",
8384
):
8485
"""
8586
Parameters:
@@ -109,6 +110,7 @@ def __init__(
109110
concurrency_limit: If set, this is the maximum number of chatbot submissions that can be running simultaneously. Can be set to None to mean no limit (any number of chatbot submissions can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `.queue()`, which is 1 by default).
110111
fill_height: If True, the chat interface will expand to the height of window.
111112
delete_cache: A tuple corresponding [frequency, age] both expressed in number of seconds. Every `frequency` seconds, the temporary files created by this Blocks instance will be deleted if more than `age` seconds have passed since the file was created. For example, setting this to (86400, 86400) will delete temporary files every day. The cache will be deleted entirely when the server restarts. If None, no cache deletion will occur.
113+
show_progress: whether to show progress animation while running.
112114
"""
113115
super().__init__(
114116
analytics_enabled=analytics_enabled,
@@ -308,7 +310,7 @@ def __init__(
308310
self.chatbot_state = (
309311
State(self.chatbot.value) if self.chatbot.value else State([])
310312
)
311-
313+
self.show_progress = show_progress
312314
self._setup_events()
313315
self._setup_api()
314316

@@ -343,6 +345,9 @@ def _setup_events(self) -> None:
343345
concurrency_limit=cast(
344346
Union[int, Literal["default"], None], self.concurrency_limit
345347
),
348+
show_progress=cast(
349+
Literal["full", "minimal", "hidden"], self.show_progress
350+
),
346351
)
347352
)
348353
self._setup_stop_events(submit_triggers, submit_event)
@@ -371,6 +376,9 @@ def _setup_events(self) -> None:
371376
concurrency_limit=cast(
372377
Union[int, Literal["default"], None], self.concurrency_limit
373378
),
379+
show_progress=cast(
380+
Literal["full", "minimal", "hidden"], self.show_progress
381+
),
374382
)
375383
)
376384
self._setup_stop_events([self.retry_btn.click], retry_event)

gradio/interface.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import warnings
1111
import weakref
12-
from typing import TYPE_CHECKING, Any, Callable, Literal
12+
from typing import TYPE_CHECKING, Any, Callable, Literal, cast
1313

1414
from gradio_client.documentation import document
1515

@@ -131,6 +131,7 @@ def __init__(
131131
stop_btn: str | Button = "Stop",
132132
clear_btn: str | Button | None = "Clear",
133133
delete_cache: tuple[int, int] | None = None,
134+
show_progress: Literal["full", "minimal", "hidden"] = "full",
134135
**kwargs,
135136
):
136137
"""
@@ -166,6 +167,7 @@ def __init__(
166167
stop_btn: The button to use for stopping the interface. Defaults to a `gr.Button("Stop", variant="stop", visible=False)`. Can be set to a string (which becomes the button label) or a `gr.Button` object (which allows for more customization).
167168
clear_btn: The button to use for clearing the inputs. Defaults to a `gr.Button("Clear", variant="secondary")`. Can be set to a string (which becomes the button label) or a `gr.Button` object (which allows for more customization). Can be set to None, which hides the button.
168169
delete_cache: A tuple corresponding [frequency, age] both expressed in number of seconds. Every `frequency` seconds, the temporary files created by this Blocks instance will be deleted if more than `age` seconds have passed since the file was created. For example, setting this to (86400, 86400) will delete temporary files every day. The cache will be deleted entirely when the server restarts. If None, no cache deletion will occur.
170+
show_progress: whether to show progress animation while running. Has no effect if the interface is `live`.
169171
"""
170172
super().__init__(
171173
analytics_enabled=analytics_enabled,
@@ -415,6 +417,7 @@ def __init__(
415417

416418
self.flagging_callback = flagging_callback
417419
self.flagging_dir = flagging_dir
420+
self.show_progress = show_progress
418421

419422
self.batch = batch
420423
self.max_batch_size = max_batch_size
@@ -732,6 +735,9 @@ async def cleanup():
732735
batch=self.batch,
733736
max_batch_size=self.max_batch_size,
734737
concurrency_limit=self.concurrency_limit,
738+
show_progress=cast(
739+
Literal["full", "minimal", "hidden"], self.show_progress
740+
),
735741
)
736742

737743
final_event = predict_event.then(

js/statustracker/static/index.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
(status === "pending" || status === "error")) ||
199199
translucent ||
200200
show_progress === "minimal"}
201-
class:generating={status === "generating"}
201+
class:generating={status === "generating" && show_progress === "full"}
202202
class:border
203203
style:position={absolute ? "absolute" : "static"}
204204
style:padding={absolute ? "0" : "var(--size-8) 0"}

0 commit comments

Comments
 (0)