Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug that shows GPT 4o even if there is no token #122

Merged
merged 3 commits into from
Sep 2, 2024
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
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", , "edgar@posit.co", 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
Loading