Skip to content

Commit

Permalink
make argument consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ABucket committed Oct 15, 2024
1 parent 5e9a1ef commit 0c81060
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions gradio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,8 @@ def log_message(
return
blocks._queue.log_message(
event_id=event_id,
title=title,
log=message,
title=title,
level=level,
duration=duration,
visible=visible,
Expand All @@ -1065,10 +1065,10 @@ def log_message(

@document(documentation_group="modals")
def Warning( # noqa: N802
title: str = "Warning",
message: str = "Warning issued.",
duration: float | None = 10,
visible: bool = True,
title: str = "Warning",
):
"""
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 for this behavior; otherwise, the warning will be printed to the console using the `warnings` library.
Expand All @@ -1077,6 +1077,7 @@ def Warning( # noqa: N802
message: The warning message to be displayed to the user. Can be HTML, which will be rendered in the modal.
duration: The duration in seconds that the warning message should be displayed for. If None or 0, the message will be displayed indefinitely until the user closes it.
visible: Whether the error message should be displayed in the UI.
title: The title to be displayed to the user. Can be HTML, which will be rendered in the modal.
Example:
import gradio as gr
def hello_world():
Expand All @@ -1087,24 +1088,24 @@ def hello_world():
demo.load(hello_world, inputs=None, outputs=[md])
demo.queue().launch()
"""
log_message(title, message, level="warning", duration=duration, visible=visible)
log_message(message, title=title, level="warning", duration=duration, visible=visible)


@document(documentation_group="modals")
def Info( # noqa: N802
message: str = "Info issued.",
title: str = "Info",
duration: float | None = 10,
visible: bool = True,
title: str = "Info",
):
"""
This function allows you to pass custom info messages to the user. You can do so simply by writing `gr.Info('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 gray by default and has the heading: "Info." Queue must be enabled for this behavior; otherwise, the message will be printed to the console.
Demos: blocks_chained_events
Parameters:
message: The info message to be displayed to the user. Can be HTML, which will be rendered in the modal.
title: The title to be displayed to the user. Can be HTML, which will be rendered in the modal.
duration: The duration in seconds that the info message should be displayed for. If None or 0, the message will be displayed indefinitely until the user closes it.
visible: Whether the error message should be displayed in the UI.
title: The title to be displayed to the user. Can be HTML, which will be rendered in the modal.
Example:
import gradio as gr
def hello_world():
Expand All @@ -1115,4 +1116,4 @@ def hello_world():
demo.load(hello_world, inputs=None, outputs=[md])
demo.queue().launch()
"""
log_message(title, message, level="info", duration=duration, visible=visible)
log_message(message, title=title, level="info", duration=duration, visible=visible)
2 changes: 1 addition & 1 deletion gradio/queueing.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ def log_message(
for event in events:
if event._id == event_id:
log_message = LogMessage(
title=title,
log=log,
level=level,
duration=duration,
visible=visible,
title=title
)
self.send_message(event, log_message)

Expand Down
4 changes: 2 additions & 2 deletions gradio/server_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class ProgressMessage(BaseMessage):

class LogMessage(BaseMessage):
msg: Literal[ServerMessage.log] = ServerMessage.log # type: ignore
title: str
log: str
level: Literal["info", "warning"]
duration: Optional[float] = 10
visible: bool = True
title: str


class EstimationMessage(BaseMessage):
Expand All @@ -45,9 +45,9 @@ class ProcessStartsMessage(BaseMessage):

class ProcessCompletedMessage(BaseMessage):
msg: Literal[ServerMessage.process_completed] = ServerMessage.process_completed # type: ignore
title: Optional[str] = None
output: dict
success: bool
title: Optional[str] = None


class ProcessGeneratingMessage(BaseMessage):
Expand Down

0 comments on commit 0c81060

Please sign in to comment.