diff --git a/DESCRIPTION b/DESCRIPTION index 51a97ab..2deeaf6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: chattr Title: Interact with Large Language Models in 'RStudio' -Version: 0.2.0 +Version: 0.2.0.9000 Authors@R: c( person("Edgar", "Ruiz", , "edgar@posit.co", role = c("aut", "cre")), person(given = "Posit Software, PBC", role = c("cph", "fnd")) diff --git a/NEWS.md b/NEWS.md index 45f5e65..eab38c9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# chattr (dev) + +* Prevents OpenAI 4o from showing as an option if no token is found + # chattr 0.2.0 ## General diff --git a/R/chattr-use.R b/R/chattr-use.R index d3e00e7..0eb6293 100644 --- a/R/chattr-use.R +++ b/R/chattr-use.R @@ -93,6 +93,7 @@ ch_get_ymls <- function(menu = TRUE) { if (!gpt_exists) { prep_files$gpt35 <- NULL prep_files$gpt4 <- NULL + prep_files$gpt4o <- NULL } if (!dbrx_exists) { diff --git a/tests/testthat/_snaps/chattr-use.md b/tests/testthat/_snaps/chattr-use.md index 506f740..b22b1d5 100644 --- a/tests/testthat/_snaps/chattr-use.md +++ b/tests/testthat/_snaps/chattr-use.md @@ -12,6 +12,13 @@ Output [1] "OpenAI - Chat Completions - gpt-4 (gpt4) \n" +--- + + Code + out$gpt4o + Output + [1] "OpenAI - Chat Completions - gpt-4o (gpt4o) \n" + # Menu works Code diff --git a/tests/testthat/test-chattr-use.R b/tests/testthat/test-chattr-use.R index 5f780d7..5ecbc8b 100644 --- a/tests/testthat/test-chattr-use.R +++ b/tests/testthat/test-chattr-use.R @@ -6,10 +6,28 @@ test_that("Request submission works", { expect_equal(class(out), "list") expect_snapshot(out$gpt35) expect_snapshot(out$gpt4) + expect_snapshot(out$gpt4o) } ) }) +test_that("Missing token prevents showing the option", { + withr::with_envvar( + new = c( + "OPENAI_API_KEY" = NA, + "DATABRICKS_TOKEN" = "test", + "DATABRICKS_HOST" = "test" + ), + { + out <- ch_get_ymls(menu = FALSE) + expect_null(out$gpt35) + expect_null(out$gpt4) + expect_null(out$gpt4o) + } + ) +}) + + test_that("Menu works", { skip_on_cran() withr::with_envvar(