From e2a1a1550bf74bedbe2e205aadb7a53899dcdaac Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 17 Dec 2024 15:23:45 -0600 Subject: [PATCH] Tweak suggested shiny app code --- docs/web-apps.qmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/web-apps.qmd b/docs/web-apps.qmd index b14c714..fc6a480 100644 --- a/docs/web-apps.qmd +++ b/docs/web-apps.qmd @@ -17,18 +17,18 @@ Using Shiny's [`ui.Chat` component](https://shiny.posit.co/py/components/display from chatlas import ChatAnthropic from shiny.express import ui -chat_ui = ui.Chat( +chat = ui.Chat( id="ui_chat", messages=["Hi! How can I help you today?"], ) -chat_ui.ui() +chat.ui() -chat = ChatAnthropic() +chat_model = ChatAnthropic() @chat_ui.on_user_submit -async def _(): - response = chat.stream(chat_ui.user_input()) - await chat_ui.append_message_stream(response) +async def handle_user_input(): + response = chat_model.stream(chat.user_input()) + await chat.append_message_stream(response) ``` ## Streamlit