Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Chat append incremental #1799

Merged
merged 9 commits into from
Dec 21, 2024
8 changes: 7 additions & 1 deletion js/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Message = {
role: "user" | "assistant";
chunk_type: "message_start" | "message_end" | null;
content_type: ContentType;
operation: "append" | null;
};
type ShinyChatMessage = {
id: string;
Expand Down Expand Up @@ -423,7 +424,12 @@ class ChatContainer extends LightElement {
return;
}

lastMessage.setAttribute("content", message.content);
const content =
message.operation === "append"
? lastMessage.getAttribute("content") + message.content
: message.content;

lastMessage.setAttribute("content", content);

if (message.chunk_type === "message_end") {
this.lastMessage?.removeAttribute("streaming");
Expand Down
2 changes: 1 addition & 1 deletion shiny/www/py-shiny/chat/chat.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions shiny/www/py-shiny/chat/chat.js.map

Large diffs are not rendered by default.

Loading