Skip to content

Commit

Permalink
Update deps, remove elmer from example (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Dec 17, 2024
1 parent 4fe6f23 commit e99773b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
6 changes: 2 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ Imports:
bslib,
coro,
htmltools,
promises (>= 1.3.2),
rlang,
shiny (> 1.9.1)
shiny (>= 1.10.0)
Suggests:
promises,
testthat (>= 3.0.0)
Remotes:
rstudio/shiny
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Expand Down
32 changes: 25 additions & 7 deletions R/chat.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,42 @@ chat_ui <- function(
#'
#' @examplesIf interactive()
#' library(shiny)
#' library(coro)
#' library(bslib)
#' library(elmer)
#' library(shinychat)
#'
#'
#' # Dumbest chatbot in the world: ignores user input and chooses
#' # a random, vague response. For a chatbot, try {elmer}.
#' fake_chatbot <- async_generator(function(input) {
#' responses <- c(
#' "What does that suggest to you?",
#' "I see.",
#' "I'm not sure I understand you fully.",
#' "What do you think?",
#' "Can you elaborate on that?",
#' "Interesting question! Let's examine thi... **See more**"
#' )
#'
#' await(async_sleep(1))
#' for (chunk in strsplit(sample(responses, 1), "")[[1]]) {
#' yield(chunk)
#' await(async_sleep(0.02))
#' }
#' })
#'
#' ui <- page_fillable(
#' chat_ui("chat", fill = TRUE)
#' )
#'
#' server <- function(input, output, session) {
#' chat <- chat_openai(model = "gpt-4o")
#'
#' server <- function(input, output, session) {
#' observeEvent(input$chat_user_input, {
#' response <- chat$stream_async(input$chat_user_input)
#' response <- fake_chatbot(input$chat_user_input)
#' chat_append("chat", response)
#' })
#' }
#'
#'
#' shinyApp(ui, server)
#'
#' @export
chat_append <- function(id, response, role = c("assistant", "user"), session = getDefaultReactiveDomain()) {
role <- match.arg(role)
Expand Down
25 changes: 21 additions & 4 deletions man/chat_append.Rd

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

0 comments on commit e99773b

Please sign in to comment.