@@ -39,12 +39,14 @@ class isStreamingMessage(TypedDict):
3939@add_example ()
4040class MarkdownStream :
4141 """
42- Stream markdown ( or HTML) content.
42+ A component for streaming markdown or HTML content.
4343
4444 Parameters
4545 ----------
4646 id
47- A unique identifier for this markdown stream.
47+ A unique identifier for this `MarkdownStream`. In Shiny Core, make sure this id
48+ matches a corresponding :func:`~shiny.ui.markdown_stream_ui` call in the app's
49+ UI.
4850 on_error
4951 How to handle errors that occur while streaming. When `"unhandled"`,
5052 the app will stop running when an error occurs. Otherwise, a notification
@@ -92,7 +94,7 @@ def ui(
9294 height : CssUnit = "auto" ,
9395 ) -> Tag :
9496 """
95- Get the UI element for this markdown stream .
97+ Create a UI element for this `MarkdownStream` .
9698
9799 This method is only relevant for Shiny Express. In Shiny Core, use
98100 :func:`~shiny.ui.markdown_stream_ui` for placing the markdown stream
@@ -136,15 +138,23 @@ async def stream(
136138 clear : bool = True ,
137139 ):
138140 """
139- Stream content into the markdown stream.
141+ Send a stream of content to the UI.
142+
143+ This method streams content into the relevant UI element.
140144
141145 Parameters
142146 ----------
143147 content
144- The content to stream. This can be any iterable of strings, such as a list,
145- generator, or file-like object.
148+ The content to stream. This can be a Iterable or an AsyncIterable of strings.
149+ Note that this includes synchronous and asynchronous generators, which is
150+ a useful way to stream content in as it arrives (e.g. from a LLM).
146151 clear
147152 Whether to clear the existing content before streaming the new content.
153+
154+ Note
155+ ----
156+ If you already have the content available as a string, you can do
157+ `.stream([content])` to set the content.
148158 """
149159
150160 content = _utils .wrap_async_iterable (content )
@@ -235,15 +245,16 @@ def markdown_stream_ui(
235245 height : CssUnit = "auto" ,
236246) -> Tag :
237247 """
238- Create a UI element for a markdown stream .
248+ Create a UI element for a :class:`~shiny.ui.MarkdownStream` .
239249
240250 This method is only relevant for Shiny Core. In Shiny Express, use
241251 :meth:`~shiny.ui.MarkdownStream.ui` to get the UI element for the markdown stream
242252
243253 Parameters
244254 ----------
245255 id
246- A unique identifier for this markdown stream.
256+ A unique identifier for the UI element containing the markdown stream.
257+ This id should match the id of the :class:`~shiny.ui.MarkdownStream` instance.
247258 content
248259 Some content to display before any streaming occurs.
249260 content_type
0 commit comments