Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Oct 15, 2024
1 parent f1c40ae commit 85c4c85
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions R/chat.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,27 @@ chat_ui <- function(
stop("Each message must be a string or a named list.")
}

tag("shiny-chat-message", list(content = x[["content"]], role = x[["role"]))
if (isTRUE(x[["role"]] == "user")) {
tag_name <- "shiny-user-message"
} else {
tag_name <- "shiny-chat-message"
}

tag(tag_name, list(content = x[["content"]]))
})

res <- tag("shiny-chat-container", list(
res <- tag("shiny-chat-container", rlang::list2(
id = id,
style = css(
width = width,
height = height
),
placeholder = placeholder,
fill = if (isTRUE(fill)) NA else NULL,
...,
tag("shiny-chat-messages", message_tags),
tag("shiny-chat-input", message_tags)
chat_deps(),
...
tag("shiny-chat-input", list(id=paste0(id, "_user_input"), placeholder=placeholder)),
chat_deps()
))

if (isTRUE(fill)) {
Expand Down

0 comments on commit 85c4c85

Please sign in to comment.