if (FALSE) { # interactive()
library(shiny)
library(bslib)
library(shinychat)
ui <- function(request) {
page_fillable(
chat_ui("chat", fill = TRUE)
)
}
server <- function(input, output, session) {
chat_client <- ellmer::chat_ollama(
system_prompt = "Important: Always respond in a limerick",
model = "qwen2.5-coder:1.5b",
echo = TRUE
)
# Update bookmark to chat on user submission and completed response
chat_restore("chat", chat_client)
observeEvent(input$chat_user_input, {
stream <- chat_client$stream_async(input$chat_user_input)
chat_append("chat", stream)
})
}
# Enable bookmarking!
shinyApp(ui, server, enableBookmarking = "server")
}
Run the code above in your browser using DataLab