diff --git a/pkg-r/DESCRIPTION b/pkg-r/DESCRIPTION index e8bd4104..ec391e9a 100644 --- a/pkg-r/DESCRIPTION +++ b/pkg-r/DESCRIPTION @@ -16,6 +16,7 @@ Depends: R (>= 4.1.0) Imports: bslib, + cli, DBI, duckdb, ellmer (>= 0.3.0), diff --git a/pkg-r/R/QueryChat.R b/pkg-r/R/QueryChat.R index 349f6301..274ebba4 100644 --- a/pkg-r/R/QueryChat.R +++ b/pkg-r/R/QueryChat.R @@ -159,7 +159,7 @@ QueryChat <- R6::R6Class( # Validate table name if (!grepl("^[a-zA-Z][a-zA-Z0-9_]*$", table_name)) { - rlang::abort( + cli::cli_abort( "Table name must begin with a letter and contain only letters, numbers, and underscores" ) } @@ -192,7 +192,7 @@ QueryChat <- R6::R6Class( if (cleanup) { shiny::onStop(function() { - message("Closing data source...") + cli::cli_inform("Closing data source...") self$cleanup() }) } @@ -462,7 +462,7 @@ QueryChat <- R6::R6Class( session = shiny::getDefaultReactiveDomain() ) { if (is.null(session)) { - rlang::abort( + cli::cli_abort( "$server() must be called within a Shiny server function." ) } diff --git a/pkg-r/R/data_source.R b/pkg-r/R/data_source.R index e8129ab6..4f8e6633 100644 --- a/pkg-r/R/data_source.R +++ b/pkg-r/R/data_source.R @@ -21,7 +21,7 @@ as_querychat_data_source.data.frame <- function(x, table_name, ...) { length(table_name) == 1 && grepl("^[a-zA-Z][a-zA-Z0-9_]*$", table_name, perl = TRUE) if (!is_table_name_ok) { - rlang::abort( + cli::cli_abort( "`table_name` argument must be a string containing alphanumeric characters and underscores, starting with a letter." ) } @@ -45,18 +45,16 @@ as_querychat_data_source.DBIConnection <- function(x, table_name, ...) { # Character string - keep as is } else { # Invalid input - rlang::abort( + cli::cli_abort( "`table_name` must be a single character string or a DBI::Id object" ) } # Check if table exists if (!DBI::dbExistsTable(x, table_name)) { - rlang::abort(paste0( - "Table ", - DBI::dbQuoteIdentifier(x, table_name), - " not found in database. If you're using a table in a catalog or schema, pass a DBI::Id", - " object to `table_name`" + cli::cli_abort(c( + "Table {DBI::dbQuoteIdentifier(x, table_name)} not found in database.", + "i" = "If you're using a table in a catalog or schema, pass a DBI::Id object to `table_name`" )) } diff --git a/pkg-r/R/querychat_module.R b/pkg-r/R/querychat_module.R index 7496fedb..4b2ed09f 100644 --- a/pkg-r/R/querychat_module.R +++ b/pkg-r/R/querychat_module.R @@ -71,7 +71,7 @@ mod_server <- function( greeting_content <- if (!is.null(greeting) && any(nzchar(greeting))) { greeting } else { - rlang::warn(c( + cli::cli_warn(c( "No greeting provided to `QueryChat()`. Using the LLM `client` to generate one now.", "i" = "For faster startup, lower cost, and determinism, consider providing a greeting to `QueryChat()` and `$generate_greeting()` to generate one beforehand." )) diff --git a/pkg-r/R/utils-ellmer.R b/pkg-r/R/utils-ellmer.R index 51002f8d..518c08f5 100644 --- a/pkg-r/R/utils-ellmer.R +++ b/pkg-r/R/utils-ellmer.R @@ -36,8 +36,8 @@ as_querychat_client <- function(client = NULL) { } if (!inherits(client, "Chat")) { - rlang::abort( - "`client` must be an {ellmer} Chat object or a function that returns one.", + cli::cli_abort( + "`client` must be an {ellmer} Chat object or a function that returns one." ) }