diff --git a/R/pal-class.R b/R/pal-class.R index 4bc9d23..bcfcba2 100644 --- a/R/pal-class.R +++ b/R/pal-class.R @@ -13,9 +13,8 @@ Pal <- R6::R6Class( .stash_last_pal(self) }, - chat = function(expr) { - request <- deparse(substitute(expr)) - private$.chat(request) + chat = function(...) { + private$Chat$chat(...) }, stream = function(expr) { request <- deparse(substitute(expr)) @@ -31,15 +30,6 @@ Pal <- R6::R6Class( ), private = list( Chat = NULL, - .chat = function(request, call = caller_env()) { - if (identical(request, "")) { - cli::cli_abort("Please supply a non-empty chat request.", call = call) - } - structure( - private$Chat$chat(paste0(request, collapse = "\n")), - class = c("pal_response", "character") - ) - }, .stream = function(request, call = caller_env()) { if (identical(request, "")) { cli::cli_abort("Please supply a non-empty chat request.", call = call) diff --git a/man-roxygen/manual-interface.R b/man-roxygen/manual-interface.R index 0371e55..3ef1e07 100644 --- a/man-roxygen/manual-interface.R +++ b/man-roxygen/manual-interface.R @@ -10,6 +10,6 @@ #' Then, to submit a query, run: #' #' ```r -#' pal_<%= role %>$chat({expr}) +#' pal_<%= role %>$chat({x}) #' ``` #' @md diff --git a/man/pal_cli.Rd b/man/pal_cli.Rd index 334a55a..1e524dd 100644 --- a/man/pal_cli.Rd +++ b/man/pal_cli.Rd @@ -180,7 +180,7 @@ pal directly, use: Then, to submit a query, run: -\if{html}{\out{
}}\preformatted{pal_cli$chat(\{expr\}) +\if{html}{\out{
}}\preformatted{pal_cli$chat(\{x\}) }\if{html}{\out{
}} } diff --git a/man/pal_roxygen.Rd b/man/pal_roxygen.Rd index e77aab1..b505f0b 100644 --- a/man/pal_roxygen.Rd +++ b/man/pal_roxygen.Rd @@ -155,7 +155,7 @@ pal directly, use: Then, to submit a query, run: -\if{html}{\out{
}}\preformatted{pal_roxygen$chat(\{expr\}) +\if{html}{\out{
}}\preformatted{pal_roxygen$chat(\{x\}) }\if{html}{\out{
}} } diff --git a/man/pal_testthat.Rd b/man/pal_testthat.Rd index 153acda..bc098b6 100644 --- a/man/pal_testthat.Rd +++ b/man/pal_testthat.Rd @@ -173,7 +173,7 @@ pal directly, use: Then, to submit a query, run: -\if{html}{\out{
}}\preformatted{pal_testthat$chat(\{expr\}) +\if{html}{\out{
}}\preformatted{pal_testthat$chat(\{x\}) }\if{html}{\out{
}} } diff --git a/tests/testthat/_snaps/pal-class.md b/tests/testthat/_snaps/pal-class.md index 8a6cc69..a6bb149 100644 --- a/tests/testthat/_snaps/pal-class.md +++ b/tests/testthat/_snaps/pal-class.md @@ -3,6 +3,6 @@ Code cli_pal$chat() Condition - Error in `cli_pal$chat()`: - ! Please supply a non-empty chat request. + Error in `user_turn()`: + ! Must supply at least one input. diff --git a/tests/testthat/test-pal-class.R b/tests/testthat/test-pal-class.R index 7e418c1..32b6ab3 100644 --- a/tests/testthat/test-pal-class.R +++ b/tests/testthat/test-pal-class.R @@ -4,8 +4,7 @@ test_that("can find the previous pal", { withr::local_options(.pal_fn = NULL, .pal_args = NULL) cli_pal <- .init_pal("cli") - expect_no_error(response <- cli_pal$chat(stop("Error message here"))) - expect_s3_class(response, "pal_response") + expect_no_error(response <- cli_pal$chat("stop(\"Error message here\")")) }) test_that("chat errors informatively with no input", { @@ -23,12 +22,12 @@ test_that("pal_chat effectively integrates system prompt", { withr::local_options(.pal_fn = NULL, .pal_args = NULL) cli_pal <- .init_pal("cli") - response <- cli_pal$chat(stop("Error message here")) + response <- cli_pal$chat("stop(\"Error message here\")") expect_true(grepl("cli_abort", response)) expect_true(grepl("Error message here", response)) testthat_pal <- .init_pal("testthat") - response <- testthat_pal$chat(expect_error(beep_bop_boop())) + response <- testthat_pal$chat("expect_error(beep_bop_boop())") expect_true(grepl("expect_snapshot", response)) expect_true(grepl("beep_bop_boop", response)) })