diff --git a/gradio/helpers.py b/gradio/helpers.py index 08c80ab50b467..be80e15d107d4 100644 --- a/gradio/helpers.py +++ b/gradio/helpers.py @@ -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, @@ -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. @@ -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(): @@ -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(): @@ -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) diff --git a/gradio/queueing.py b/gradio/queueing.py index 15dacdc788781..5f6f4416f9862 100644 --- a/gradio/queueing.py +++ b/gradio/queueing.py @@ -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) diff --git a/gradio/server_messages.py b/gradio/server_messages.py index 5327ff29c8a1b..7eadc4437d2a5 100644 --- a/gradio/server_messages.py +++ b/gradio/server_messages.py @@ -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): @@ -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):