Skip to content

Commit e1d7599

Browse files
committed
Undo unwanted changes to starter template
1 parent ed6cae6 commit e1d7599

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed
Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,31 @@
1-
from shiny.express import expressify, ui
1+
from shiny.express import ui
22

3+
# Set some Shiny page options
4+
ui.page_opts(
5+
title="Hello Shiny Chat",
6+
fillable=True,
7+
fillable_mobile=True,
8+
)
39

4-
@expressify
5-
def card_suggestion(title: str, suggestion: str, img_src: str, img_alt: str):
6-
with ui.card(data_suggestion=suggestion):
7-
ui.card_header(title)
8-
ui.img(
9-
src=img_src,
10-
alt=img_alt,
11-
style="margin-top:auto; margin-bottom:auto;",
12-
)
13-
14-
15-
@expressify
16-
def card_suggestions():
17-
with ui.layout_column_wrap():
18-
card_suggestion(
19-
title="Learn Python",
20-
suggestion="Teach me Python",
21-
img_src="https://upload.wikimedia.org/wikipedia/commons/c/c3/Python-logo-notext.svg",
22-
img_alt="Python logo",
23-
)
24-
card_suggestion(
25-
title="Learn R",
26-
suggestion="Teach me R",
27-
img_src="https://upload.wikimedia.org/wikipedia/commons/1/1b/R_logo.svg",
28-
img_alt="R logo",
29-
)
30-
31-
32-
with ui.hold() as suggestions:
33-
card_suggestions()
34-
35-
welcome = f"""
36-
**Hello!** How can I help you today?
37-
38-
Here are a couple suggestions:
39-
40-
{suggestions[0]}
10+
# Create a welcome message
11+
welcome = """
12+
Hi! This is a simple Shiny `Chat` UI. Enter a message below and I will
13+
simply repeat it back to you. For more examples, see this
14+
[folder of examples](https://github.com/posit-dev/py-shiny/tree/main/shiny/templates/chat).
4115
"""
4216

17+
# Create a chat instance
4318
chat = ui.Chat(
4419
id="chat",
4520
messages=[welcome],
4621
)
4722

23+
# Display it
4824
chat.ui()
4925

5026

27+
# Define a callback to run when the user submits a message
5128
@chat.on_user_submit
5229
async def handle_user_input(user_input: str):
30+
# Append a response to the chat
5331
await chat.append_message(f"You said: {user_input}")

0 commit comments

Comments
 (0)