chat_greeting

chat_greeting(content, *, dismissible=True)

Create a greeting for a chat UI.

A greeting is a welcome message displayed at the top of the chat before any conversation messages. It can be static (set via :func:~shinychat.chat_ui) or dynamic (set via :meth:~shinychat.Chat.set_greeting).

Parameters

Name Type Description Default
content Union[str, HTML, Tag, TagList, 'AsyncIterable[str]'] The greeting content. Can be a markdown string, :class:~htmltools.HTML, :class:~htmltools.Tag, :class:~htmltools.TagList, or an :class:~typing.AsyncIterable of strings (streaming, only valid via :meth:~shinychat.Chat.set_greeting). required
dismissible bool Whether the greeting can be dismissed when the user sends a message. When True (the default), the greeting is hidden once the user sends their first message. Set to False to keep the greeting visible throughout the conversation, which is useful for persistent instructions or navigation. True

Examples

Basic greeting:

from shinychat import chat_greeting

chat_greeting("## Welcome!\n\nHow can I help you today?")

Non-dismissible greeting that stays visible:

chat_greeting("Please select a topic to get started.", dismissible=False)

Greeting with suggestion cards (uses <span class="suggestion">):

chat_greeting(
    "## Welcome!\n\n"
    '<span class="suggestion">Summarize this dataset</span>\n'
    '<span class="suggestion">Show me recent trends</span>'
)

See Also

: Set a static greeting in the UI definition. : Set or stream a greeting from the server.