Chat
Render a chat thread and composer from a Python-owned message list.
Notes
Assigning messages replaces the list; mutating it in place does not
sync. To stream a reply, replace the last message with its longer
content::
chat.messages = [*chat.messages[:-1], {"role": "assistant", "content": text}]Submitting does not append the user message. Submit callbacks decide what the thread shows.
See Astryx component docs: https://astryx.atmeta.com/components/ChatLayout.
Attributes
attributemessages= t.List(t.Dict(), default_value=[]).tag(sync=True)attributeis_streaming= t.Bool(False).tag(sync=True)attributeplaceholder= t.Unicode('').tag(sync=True)Functions
constructor__init__(messages=(), *, is_streaming=False, placeholder='', disabled=False, width=None, height=480, **props) -> NoneparammessagesIterable[Mapping[str, Any]]= ()Messages in display order. Each message has a role of "user",
"assistant", or "system", Markdown content, an optional
status of "sending", "sent", "error", or "stopped",
and optional tool_calls. Each tool call has a name, an optional
target, and a status of "pending", "running",
"complete", or "error".
paramis_streamingbool= FalseWhether an assistant turn is in progress. While it is, the composer shows a stop control instead of the send button, and the last assistant message renders in streaming mode.
paramplaceholderstr= ''Composer placeholder. Empty uses the Astryx default.
paramdisabledbool= FalseWhether the composer is disabled. A disabled chat ignores submits.
paramwidthint | float | str | None= NoneCSS width. Numbers are normalized by anylumino where supported.
paramheightint | float | str | None= 480CSS height. The thread scrolls inside this height, so it needs a definite value. Numbers are normalized by anylumino where supported.
parampropsAny= {}Returns
Nonefuncon_submit(callback, remove=False) -> NoneRegister or unregister a callback receiving the chat and the submitted text.
paramcallbackCallable[[Chat, str], None]paramremovebool= FalseReturns
Nonefuncon_stop(callback, remove=False) -> NoneRegister or unregister a callback for the composer stop control.
paramcallbackCallable[[Chat], None]paramremovebool= FalseReturns
None