https://github.com/jcheng5/shinychat
Chat UI component for Shiny for R
https://github.com/jcheng5/shinychat
Last synced: 16 days ago
JSON representation
Chat UI component for Shiny for R
- Host: GitHub
- URL: https://github.com/jcheng5/shinychat
- Owner: posit-dev
- License: other
- Created: 2024-09-18T22:50:10.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-27T20:58:09.000Z (24 days ago)
- Last Synced: 2025-03-29T12:03:00.861Z (23 days ago)
- Language: R
- Homepage: https://posit-dev.github.io/shinychat/
- Size: 1.58 MB
- Stars: 73
- Watchers: 9
- Forks: 10
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - jcheng5/shinychat - Chat UI component for Shiny for R (R)
README
# shinychat
[](https://github.com/posit-dev/shinychat/actions/workflows/R-CMD-check.yaml)
Chat UI component for [Shiny for R](https://shiny.posit.co/).
(For [Shiny for Python](https://shiny.posit.co/py/), see [ui.Chat](https://shiny.posit.co/py/components/display-messages/chat/).)
## Installation
You can install shinychat from CRAN with:
``` r
install.packages("shinychat")
```Or, install the development version of shinychat from [GitHub](https://github.com/) with:
``` r
# install.packages("pak")
pak::pak("posit-dev/shinychat")
```## Example
To run this example, you'll first need to create an OpenAI API key, and set it in your environment as `OPENAI_API_KEY`.
You'll also need to call `pak::pak("tidyverse/ellmer")` to install the {[ellmer](https://ellmer.tidyverse.org/)} package.
```r
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)
```