diff --git a/shiny/api-examples/Chat/app-core.py b/shiny/api-examples/Chat/app-core.py index 4c4dc79c5..35aefb0b6 100644 --- a/shiny/api-examples/Chat/app-core.py +++ b/shiny/api-examples/Chat/app-core.py @@ -3,21 +3,24 @@ app_ui = ui.page_fillable( ui.panel_title("Hello Shiny Chat"), ui.chat_ui("chat"), - fillable_mobile=True, -) - -# Create a welcome message -welcome = """ + ui.chat_ui( + "chat", + messages=[ + """ Hi! This is a simple Shiny `Chat` UI. Enter a message below and I will simply repeat it back to you. To learn more about chatbots and how to build them with Shiny, check out [the documentation](https://shiny.posit.co/py/docs/genai-chatbots.html). """ + ], + ), + fillable_mobile=True, +) def server(input, output, session): - chat = ui.Chat(id="chat", messages=[welcome]) + chat = ui.Chat(id="chat") # Define a callback to run when the user submits a message @chat.on_user_submit diff --git a/shiny/api-examples/Chat/app-express.py b/shiny/api-examples/Chat/app-express.py index f268d0b5a..1170118f1 100644 --- a/shiny/api-examples/Chat/app-express.py +++ b/shiny/api-examples/Chat/app-express.py @@ -7,24 +7,22 @@ fillable_mobile=True, ) -# Create a welcome message -welcome = """ +# Create a chat instance +chat = ui.Chat(id="chat") + +# Display it, with a startup message +chat.ui( + messages=[ + """ Hi! This is a simple Shiny `Chat` UI. Enter a message below and I will simply repeat it back to you. To learn more about chatbots and how to build them with Shiny, check out [the documentation](https://shiny.posit.co/py/docs/genai-chatbots.html). """ - -# Create a chat instance -chat = ui.Chat( - id="chat", - messages=[welcome], + ], ) -# Display it -chat.ui() - # Define a callback to run when the user submits a message @chat.on_user_submit