Skip to content

Commit c296963

Browse files
authored
Merge pull request #113 from mlverse/updates
Updates
2 parents 14893b9 + 1c22cfd commit c296963

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: chattr
22
Title: Interact with Large Language Models in 'RStudio'
3-
Version: 0.1.0.9002
3+
Version: 0.1.0.9005
44
Authors@R: c(
55
person("Edgar", "Ruiz", , "[email protected]", role = c("aut", "cre")),
66
person(given = "Posit Software, PBC", role = c("cph", "fnd"))

NEWS.md

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ notebook or the app
1818
* Fixes how the errors from OpenAI are parsed and processed. This should make
1919
it easier for users to determine where an downstream issue could be.
2020

21+
## Copilot
22+
23+
* Adds `model` to defaults
24+
25+
* Improves token discovery
26+
2127
# chattr 0.1.0
2228

2329
* Initial CRAN submission.

R/backend-openai.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ ch_gh_token <- function(defaults = NULL, fail = TRUE) {
139139
}
140140
gh_path <- path_expand(hosts_path)
141141
if (dir_exists(gh_path)) {
142-
hosts <- jsonlite::read_json(path(gh_path, "hosts.json"))
142+
possible_files <- c("apps.json", "hosts.json")
143+
possible_paths <- path(gh_path, possible_files)
144+
possible_exists <- file_exists(possible_paths)
145+
possible <- possible_paths[possible_exists]
146+
hosts <- jsonlite::read_json(possible[[1]])
143147
oauth_token <- hosts[[1]]$oauth_token
144148
x <- try(
145149
{

inst/configs/copilot.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ default:
88
include_doc_contents: FALSE
99
system_msg: You are a helpful coding assistant
1010
token_url: "https://api.github.com/copilot_internal/v2/token"
11+
model: gpt-4
1112
model_arguments:
1213
stream: TRUE
1314
chat:

tests/testthat/_snaps/chattr-test.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
-- chattr
6161
* Provider: OpenAI - GitHub Copilot Chat
6262
* Path/URL: https://api.githubcopilot.com/chat/completions
63-
* Model:
63+
* Model: gpt-4
6464
* Label: Copilot (GitHub)
6565

6666
---
@@ -72,7 +72,7 @@
7272
-- Testing chattr
7373
* Provider: OpenAI - GitHub Copilot Chat
7474
* Path/URL: https://api.githubcopilot.com/chat/completions
75-
* Model:
75+
* Model: gpt-4
7676
* Label: Copilot (GitHub)
7777
v Connection with GitHub Copilot cofirmed
7878
|--Prompt: TEST

tests/testthat/test-chattr-use.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ test_that("Request submission works", {
1313
test_that("Menu works", {
1414
skip_on_cran()
1515
withr::with_envvar(
16-
new = c("OPENAI_API_KEY" = "test"),
16+
new = c("OPENAI_API_KEY" = "test", "DATABRICKS_TOKEN" = NA),
1717
{
1818
local_mocked_bindings(
1919
menu = function(...) {
2020
return(1)
2121
}
2222
)
23+
print(ch_get_ymls(menu = TRUE) )
2324
expect_true(
24-
ch_get_ymls(menu = TRUE) %in% c("gpt35", "gpt4")
25+
ch_get_ymls(menu = TRUE) %in% c("gpt35", "gpt4", "gpt4o")
2526
)
2627
}
2728
)

0 commit comments

Comments
 (0)