querychat provides an interactive chat interface for querying data using natural language. It translates your questions into SQL queries, executes them against your data, and displays the results. The package works with both data frames and database connections.
The easiest way to get started is with the QueryChat R6 class:
library(querychat)# Create a QueryChat object (table name inferred from variable)
qc <- QueryChat$new(mtcars)
# Option 1: Run a complete app with sensible defaults
qc$app()
# Option 2: Build a custom Shiny app
ui <- page_sidebar(
qc$sidebar(),
dataTableOutput("data")
)
server <- function(input, output, session) {
qc$server()
output$data <- renderDataTable(qc$df())
}
shinyApp(ui, server)
Natural language queries: Ask questions in plain English
SQL transparency: See the generated SQL queries
Multiple data sources: Works with data frames and database connections
Customizable: Add data descriptions, extra instructions, and custom greetings
LLM agnostic: Works with OpenAI, Anthropic, Google, and other providers via ellmer
QueryChat: The main R6 class for creating chat interfaces
DataSource, DataFrameSource, DBISource: R6 classes for data sources
To see examples included with the package, run:
shiny::runExample(package = "querychat")
This provides a list of available examples. To run a specific example, like '01-hello-app', use:
shiny::runExample("01-hello-app", package = "querychat")
Maintainer: Garrick Aden-Buie garrick@posit.co (ORCID)
Authors:
Joe Cheng joe@posit.co [conceptor]
Carson Sievert carson@posit.co (ORCID)
Other contributors:
Posit Software, PBC [copyright holder, funder]