Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg-r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Depends:
R (>= 4.1.0)
Imports:
bslib,
cli,
DBI,
duckdb,
ellmer (>= 0.3.0),
Expand Down
6 changes: 3 additions & 3 deletions pkg-r/R/QueryChat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
}
Expand Down Expand Up @@ -192,7 +192,7 @@ QueryChat <- R6::R6Class(

if (cleanup) {
shiny::onStop(function() {
message("Closing data source...")
cli::cli_inform("Closing data source...")
self$cleanup()
})
}
Expand Down Expand Up @@ -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."
)
}
Expand Down
12 changes: 5 additions & 7 deletions pkg-r/R/data_source.R
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Comment on lines +24 to 26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um... part of wanting to use cli_abort() over rlang::abort() is to take advantage of cli's inline markup formatting

}
Expand All @@ -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`"
))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg-r/R/querychat_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -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."
))
Expand Down
4 changes: 2 additions & 2 deletions pkg-r/R/utils-ellmer.R
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
}

Expand Down