Skip to content

Commit e99773b

Browse files
committed
Update deps, remove elmer from example (for now)
1 parent 4fe6f23 commit e99773b

File tree

3 files changed

+48
-15
lines changed

3 files changed

+48
-15
lines changed

DESCRIPTION

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ Imports:
1616
bslib,
1717
coro,
1818
htmltools,
19+
promises (>= 1.3.2),
1920
rlang,
20-
shiny (> 1.9.1)
21+
shiny (>= 1.10.0)
2122
Suggests:
22-
promises,
2323
testthat (>= 3.0.0)
24-
Remotes:
25-
rstudio/shiny
2624
Encoding: UTF-8
2725
Roxygen: list(markdown = TRUE)
2826
RoxygenNote: 7.3.2

R/chat.R

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,24 +167,42 @@ chat_ui <- function(
167167
#'
168168
#' @examplesIf interactive()
169169
#' library(shiny)
170+
#' library(coro)
170171
#' library(bslib)
171-
#' library(elmer)
172172
#' library(shinychat)
173-
#'
173+
#'
174+
#' # Dumbest chatbot in the world: ignores user input and chooses
175+
#' # a random, vague response. For a chatbot, try {elmer}.
176+
#' fake_chatbot <- async_generator(function(input) {
177+
#' responses <- c(
178+
#' "What does that suggest to you?",
179+
#' "I see.",
180+
#' "I'm not sure I understand you fully.",
181+
#' "What do you think?",
182+
#' "Can you elaborate on that?",
183+
#' "Interesting question! Let's examine thi... **See more**"
184+
#' )
185+
#'
186+
#' await(async_sleep(1))
187+
#' for (chunk in strsplit(sample(responses, 1), "")[[1]]) {
188+
#' yield(chunk)
189+
#' await(async_sleep(0.02))
190+
#' }
191+
#' })
192+
#'
174193
#' ui <- page_fillable(
175194
#' chat_ui("chat", fill = TRUE)
176195
#' )
177-
#'
178-
#' server <- function(input, output, session) {
179-
#' chat <- chat_openai(model = "gpt-4o")
180196
#'
197+
#' server <- function(input, output, session) {
181198
#' observeEvent(input$chat_user_input, {
182-
#' response <- chat$stream_async(input$chat_user_input)
199+
#' response <- fake_chatbot(input$chat_user_input)
183200
#' chat_append("chat", response)
184201
#' })
185202
#' }
186-
#'
203+
#'
187204
#' shinyApp(ui, server)
205+
#'
188206
#' @export
189207
chat_append <- function(id, response, role = c("assistant", "user"), session = getDefaultReactiveDomain()) {
190208
role <- match.arg(role)

man/chat_append.Rd

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)