Skip to content

Commit

Permalink
Merge pull request #122 from mlverse/updates
Browse files Browse the repository at this point in the history
Fixes bug that shows GPT 4o even if there is no token
  • Loading branch information
edgararuiz authored Sep 2, 2024
2 parents 9824815 + 8d38734 commit ade3e10
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre")),
person(given = "Posit Software, PBC", role = c("cph", "fnd"))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# chattr (dev)

* Prevents OpenAI 4o from showing as an option if no token is found

# chattr 0.2.0

## General
Expand Down
1 change: 1 addition & 0 deletions R/chattr-use.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/_snaps/chattr-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-chattr-use.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ade3e10

Please sign in to comment.