Skip to content
Open
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
8 changes: 4 additions & 4 deletions pkg-r/R/QueryChat.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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 All @@ -168,7 +168,7 @@ QueryChat <- R6::R6Class(
self$greeting <- greeting

if (is.null(greeting)) {
rlang::warn(c(
cli::cli_warn(c(
"No greeting provided; the LLM will be invoked at conversation start to generate one.",
"*" = "For faster startup, lower cost, and determinism, please save a greeting and pass it to QueryChat$new().",
"i" = "You can generate a greeting with $generate_greeting()."
Expand Down Expand Up @@ -196,7 +196,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 @@ -455,7 +455,7 @@ QueryChat <- R6::R6Class(
#' }
server = function(session = shiny::getDefaultReactiveDomain()) {
if (is.null(session)) {
rlang::abort(
cli::cli_abort(
"$server() must be called within a Shiny server function."
)
}
Expand Down
14 changes: 6 additions & 8 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 = NULL, ...) {
# Infer table name from dataframe name, if not already added
table_name <- deparse(substitute(x))
if (is.null(table_name) || table_name == "NULL" || table_name == "x") {
rlang::abort(
cli::cli_abort(
"Unable to infer table name. Please specify `table_name` argument explicitly."
)
}
Expand All @@ -31,7 +31,7 @@ as_querychat_data_source.data.frame <- function(x, table_name = NULL, ...) {
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 a valid table name."
)
}
Expand All @@ -55,18 +55,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 @@ -60,7 +60,7 @@ mod_server <- function(id, data_source, greeting, client) {
greeting
} else {
# Generate greeting on the fly if none provided
rlang::warn(c(
cli::cli_warn(c(
"No greeting provided; generating one now. This adds latency and cost.",
"i" = "Consider using $generate_greeting() to create a reusable greeting."
))
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