Skip to content

Commit 642b7f1

Browse files
committed
Revert "First pass at updating chat component page for a chatlas world"
This reverts commit 961c3a6.
1 parent 961c3a6 commit 642b7f1

File tree

5 files changed

+148
-205
lines changed

5 files changed

+148
-205
lines changed

components/display-messages/chat/app-core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ def server(input):
1313

1414
# Define a callback to run when the user submits a message
1515
@chat.on_user_submit # <<
16-
async def handle_user_input(user_input: str): # <<
16+
async def _(): # <<
1717
# Simply echo the user's input back to them
18-
await chat.append_message(f"You said: {user_input}") # <<
18+
await chat.append_message(f"You said: {chat.user_input()}") # <<
1919

2020

2121
app = App(app_ui, server)

components/display-messages/chat/app-express.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
# Define a callback to run when the user submits a message
1515
@chat.on_user_submit # <<
16-
async def handle_user_input(user_input: str): # <<
16+
async def _(): # <<
1717
# Simply echo the user's input back to them
18-
await chat.append_message(f"You said: {user_input}") # <<
18+
await chat.append_message(f"You said: {chat.user_input()}") # <<

components/display-messages/chat/app-preview-code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414

1515
# Define a callback to run when the user submits a message
1616
@chat.on_user_submit
17-
async def handle_user_input(user_input: str):
17+
async def _():
1818
# Append a response to the chat
19-
await chat.append_message(f"You said: {user_input}")
19+
await chat.append_message(f"You said: {chat.user_input()}")

components/display-messages/chat/app-preview.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"""
1313
Hi! This is a simple Shiny `Chat` UI. Enter a message below and I will
1414
simply repeat it back to you. For more examples, see this
15-
[folder of examples](https://github.com/posit-dev/py-shiny/tree/main/shiny/templates/chat).
15+
[folder of examples](https://github.com/posit-dev/py-shiny/tree/main/examples/chat).
1616
"""
1717
)
1818

@@ -28,6 +28,11 @@
2828

2929
# Define a callback to run when the user submits a message
3030
@chat.on_user_submit
31-
async def handle_user_input(user_input: str):
31+
async def _():
32+
# Get the chat messages.
33+
messages = chat.messages()
34+
# Typically you'd pass messages to an LLM for response generation,
35+
# but for this example, we'll just echo the user's input
36+
user = messages[-1]["content"]
3237
# Append a response to the chat
33-
await chat.append_message(f"You said: {user_input}")
38+
await chat.append_message(f"You said: {user}")

0 commit comments

Comments
 (0)