Skip to content

Commit

Permalink
Revert "First pass at updating chat component page for a chatlas world"
Browse files Browse the repository at this point in the history
This reverts commit 961c3a6.
  • Loading branch information
cpsievert committed Dec 21, 2024
1 parent 961c3a6 commit 642b7f1
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 205 deletions.
4 changes: 2 additions & 2 deletions components/display-messages/chat/app-core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def server(input):

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


app = App(app_ui, server)
4 changes: 2 additions & 2 deletions components/display-messages/chat/app-express.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

# Define a callback to run when the user submits a message
@chat.on_user_submit # <<
async def handle_user_input(user_input: str): # <<
async def _(): # <<
# Simply echo the user's input back to them
await chat.append_message(f"You said: {user_input}") # <<
await chat.append_message(f"You said: {chat.user_input()}") # <<
4 changes: 2 additions & 2 deletions components/display-messages/chat/app-preview-code.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

# Define a callback to run when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
async def _():
# Append a response to the chat
await chat.append_message(f"You said: {user_input}")
await chat.append_message(f"You said: {chat.user_input()}")
11 changes: 8 additions & 3 deletions components/display-messages/chat/app-preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""
Hi! This is a simple Shiny `Chat` UI. Enter a message below and I will
simply repeat it back to you. For more examples, see this
[folder of examples](https://github.com/posit-dev/py-shiny/tree/main/shiny/templates/chat).
[folder of examples](https://github.com/posit-dev/py-shiny/tree/main/examples/chat).
"""
)

Expand All @@ -28,6 +28,11 @@

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

0 comments on commit 642b7f1

Please sign in to comment.