panel.chat.step module#
- class panel.chat.step.ChatStep(*objects, **params)[source]#
Bases:
Card
A component that makes it easy to provide status updates and the ability to stream updates to both the output(s) and the title.
Reference: https://panel.holoviz.org/reference/chat/ChatStep.html
- Example:
>>> ChatStep("Hello world!", title="Running calculation...', status="running")
Methods
serialize
([prefix_with_viewable_label, ...])Format the object to a string.
stream
(token[, replace])Stream a token to the last available string-like object.
stream_title
(token[, status, replace])Stream a token to the title header.
Parameter Definitions
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.ListPanel
: scrollpanel.layout.base.Column
: auto_scroll_limit, scroll_button_threshold, scroll_position, view_latestpanel.layout.card.Card
: css_classes, active_header_background, button_css_classes, collapsible, header_background, header_color, header_css_classes, hide_header, title_css_classesmargin = Parameter(allow_refs=True, default=(5, 5, 5, 10), label='Margin')
Allows to create additional space around the component. May be specified as a two-tuple of the form (vertical, horizontal) or a four-tuple (top, right, bottom, left).
collapsed = Boolean(default=False, label='Collapsed')
Whether the contents of the Card are collapsed.
header = Parameter(allow_None=True, constant=True, label='Header', readonly=True)
A Panel component to display in the header bar of the Card. Will override the given title if defined.
title = String(constant=True, default='', label='Title')
The title of the chat step. Will redirect to default_title on init. After, it cannot be set directly; instead use the *_title params.
collapsed_on_success = Boolean(default=True, label='Collapsed on success')
Whether to collapse the card on completion.
context_exception = Selector(default='raise', label='Context exception', names={}, objects=['raise', 'summary', 'verbose', 'ignore'])
How to handle exceptions raised upon exiting the context manager. If “raise”, the exception will be raised. If “summary”, a summary will be sent to the chat step. If “verbose”, the full traceback will be sent to the chat step. If “ignore”, the exception will be ignored.
success_title = String(allow_None=True, label='Success title')
Title to display when status is success.
default_badges = Dict(class_=<class 'dict'>, default={'pending': BooleanStatus(color='primary', margin=0), 'running': BooleanStatus(color='warning', margin=0, value=True), 'success': BooleanStatus(color='success', margin=0, value=True), 'failed': BooleanStatus(color='danger', margin=0, value=True)}, label='Default badges')
Mapping from status to default status badge; keys must be one of ‘pending’, ‘running’, ‘success’, ‘failed’.
default_title = String(default='', label='Default title')
The default title to display if the other title params are unset.
failed_title = String(allow_None=True, label='Failed title')
Title to display when status is failed.
pending_title = String(allow_None=True, label='Pending title')
Title to display when status is pending.
running_title = String(allow_None=True, label='Running title')
Title to display when status is running.
status = Selector(default='pending', label='Status', names={}, objects=['pending', 'running', 'success', 'failed'])
- serialize(prefix_with_viewable_label: bool = True, prefix_with_container_label: bool = True) str [source]#
Format the object to a string.
- Parameters:
- prefix_with_viewable_labelbool
Whether to include the name of the Viewable, or type of the viewable if no name is specified.
- prefix_with_container_labelbool
Whether to include the name of the container, or type of the container if no name is specified.
- Returns:
- str
The serialized string.
- stream(token: str | None, replace: bool = False)[source]#
Stream a token to the last available string-like object.
- Parameters:
- tokenstr
The token to stream.
- replacebool
Whether to replace the existing text.
- Returns:
- Viewable
The updated message pane.
- stream_title(token: str, status: Literal['pending', 'running', 'success', 'failed', 'default'] = 'running', replace: bool = False)[source]#
Stream a token to the title header.
- Parameters:
- tokenstr
The token to stream.
- statusstr
The status title to stream to, one of ‘pending’, ‘running’, ‘success’, ‘failed’, or “default”.
- replacebool
Whether to replace the existing text.