API reference
vizro_experimental.chat
Chat component for Vizro dashboards (experimental).
Chat
Bases: VizroBaseModel
Chat component for conversational AI interfaces.
Parameters:
-
type(Literal['chat']) –Defaults to
"chat". -
actions(list[_BaseChatAction] | _BaseChatAction) –The action that handles responses. Pass an action instance directly; the field stores it as a single-element list to match Vizro's action-chain convention. Defaults to
[]. -
placeholder(str) –Placeholder text for the input field. Defaults to
"How can I help you?". -
file_upload(bool) –Enable file upload functionality. Defaults to
False. -
example_questions(list[str]) –List of example questions to show in a popup menu. Defaults to
[].
ChatAction
Bases: _BaseChatAction
Non-streaming chat action for synchronous response generation.
Subclass this to create custom chat actions that return complete responses.
Example
outputs
property
Define callback outputs for this action.
Returns:
-
list[str]–List of output component references.
function
Execute the chat action callback.
Parameters:
-
prompt(str) –User's input text.
-
messages(list[dict[str, Any]]) –Store-shaped history (
role+content_json); mutated in place when sending. -
uploaded_files(list[dict[str, str]] | None, default:None) –File-store payload at send time. Snapshotted into the new user message as
attachmentsso the bubble renders them and the file-store can clear.
Returns:
-
list[Any]–List of outputs for store, hidden-messages, chat-input, file-store, and data-info
-
list[Any]–(matching
self.outputs).
generate_response
Generate a chat response.
Parameters:
-
messages(list[Message]) –Parsed history: each item has
roleandcontent(decoded from storecontent_json). -
**kwargs(Any, default:{}) –Optional
uploaded_filesor other kwargs only if your implementation accepts them.
Returns:
-
str | Div–Response content as string or Dash component (will be JSON-serialized automatically).
Raises:
-
NotImplementedError–Must be implemented by subclass.
Message
Bases: TypedDict
Parsed chat item passed to generate_response (decoded content_json).
attachments is present on user turns that included file uploads — each entry has
filename and content (base64 data URL). Only set when the original wire
message carried it; absent on plain text turns.
StreamingChatAction
Bases: _BaseChatAction
Streaming chat action for real-time response generation via SSE.
Subclass this to create custom chat actions that stream responses in real-time.
Example
outputs
property
Define callback outputs for this action.
Returns:
-
list[str]–List of output component references.
function
Execute the streaming chat action callback.
Parameters:
-
prompt(str) –User's input text.
-
messages(list[dict[str, Any]]) –Store-shaped history (
role+content_json); mutated in place when sending. -
uploaded_files(list[dict[str, str]] | None, default:None) –File-store payload at send time. Snapshotted into the new user message as
attachmentsso the bubble renders them and the file-store can clear.
Returns:
-
list[Any]–List of outputs for store, hidden-messages, chat-input, SSE url, SSE options,
-
list[Any]–file-store, and data-info (matching
self.outputs).
generate_response
Generate a streaming chat response.
Parameters:
-
messages(list[Message]) –Parsed history: each item has
roleandcontent(decoded from storecontent_json). -
**kwargs(Any, default:{}) –Optional
uploaded_filesor other kwargs only if your implementation accepts them.
Yields:
-
str–Text chunks to stream to the client.
Raises:
-
NotImplementedError–Must be implemented by subclass.