Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions shiny/api-examples/Chat/app-core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions shiny/api-examples/Chat/app-express.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading