library(dotenv)
library(shiny)
library(shinychat)
ui <- bslib::page_fluid(
chat_ui("chat")
)
server <- function(input, output, session) {
chat <- ellmer::chat_openai(system_prompt = "You're a trickster who answers in riddles")
observeEvent(input$chat_user_input, {
stream <- chat$stream_async(input$chat_user_input)
chat_append("chat", stream)
})
}
shinyApp(ui, server)from chatlas import ChatAnthropic
from shiny.express import ui
# Might instead be ChatAnthropic, ChatOpenAI, or some other provider
chat_client = ChatAnthropic()
chat = ui.Chat(id="my_chat")
chat.ui()
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)The New York Data Science & AI Conference. 2025. https://github.com/chendaniely/nydsaic2025-llm