Skip to content

Add messages parameter to chat_ui() and Chat.ui(); revert #1593 #1736

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Oct 15, 2024

With this PR, the messages parameter of Chat.ui()/chat_ui() becomes the suggested way to provide starting messages. For example:

Express
from shiny import reactive
from shiny.express import ui

chat = ui.Chat(id="chat")

chat.ui(messages=["Hello, how can I help?"])
Core
from shiny import App, ui

app_ui = ui.page_fixed(
    ui.chat_ui("chat", messages=["Hello, how are you?"]),
)

def server(input, output, session):
    pass

app = App(app_ui, server)

This PR also reverts #1593 since waiting until flush to send is not an ideal way to support dynamic UI. As a result, this PR also closes #1735.

In the next release, we should deprecate Chat(messages=...) in favor of these new parameters. Deprecating now feels premature since it's still convenient for things like system messages. But, when we move towards recommending chatlas/LangChain for managing chat state in a future release, we'll deprecate as a part of that move.

@cpsievert cpsievert force-pushed the chat-starting-messages branch from d6a349b to c9ee59c Compare October 15, 2024 18:54
@cpsievert cpsievert merged commit d0354b9 into main Oct 15, 2024
41 checks passed
@cpsievert cpsievert deleted the chat-starting-messages branch October 15, 2024 20:24
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible bug with LangGraph streaming introduced in v1.1.0 in ui.Chat()
2 participants