Skip to content

feat(Chat): The .append_message() method now automatically streams in generators#1800

Draft
cpsievert wants to merge 3 commits into
mainfrom
chat-append-generator
Draft

feat(Chat): The .append_message() method now automatically streams in generators#1800
cpsievert wants to merge 3 commits into
mainfrom
chat-append-generator

Conversation

@cpsievert

@cpsievert cpsievert commented Dec 17, 2024

Copy link
Copy Markdown
Collaborator

Most importantly, this'll make it so .append_message() "just works" with chatlas' .stream() method

from chatlas import ChatAnthropic
from shiny.express import ui

chat = ui.Chat(
    id="ui_chat",
    messages=["Hi! How can I help you today?"],
)
chat.ui()

chat_model = ChatAnthropic()

@chat.on_user_submit
async def _():
    response = chat_model.stream(chat.user_input())
    await chat.append_message(response)

TODO

  • Unit test
@cpsievert cpsievert marked this pull request as draft December 17, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant