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

Updates #113

Merged
merged 5 commits into from
Jul 16, 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.1.0.9002
Version: 0.1.0.9005
Authors@R: c(
person("Edgar", "Ruiz", , "[email protected]", role = c("aut", "cre")),
person(given = "Posit Software, PBC", role = c("cph", "fnd"))
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ notebook or the app
* Fixes how the errors from OpenAI are parsed and processed. This should make
it easier for users to determine where an downstream issue could be.

## Copilot

* Adds `model` to defaults

* Improves token discovery

# chattr 0.1.0

* Initial CRAN submission.
6 changes: 5 additions & 1 deletion R/backend-openai.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ ch_gh_token <- function(defaults = NULL, fail = TRUE) {
}
gh_path <- path_expand(hosts_path)
if (dir_exists(gh_path)) {
hosts <- jsonlite::read_json(path(gh_path, "hosts.json"))
possible_files <- c("apps.json", "hosts.json")
possible_paths <- path(gh_path, possible_files)
possible_exists <- file_exists(possible_paths)
possible <- possible_paths[possible_exists]
hosts <- jsonlite::read_json(possible[[1]])
oauth_token <- hosts[[1]]$oauth_token
x <- try(
{
Expand Down
1 change: 1 addition & 0 deletions inst/configs/copilot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ default:
include_doc_contents: FALSE
system_msg: You are a helpful coding assistant
token_url: "https://api.github.com/copilot_internal/v2/token"
model: gpt-4
model_arguments:
stream: TRUE
chat:
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/chattr-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
-- chattr
* Provider: OpenAI - GitHub Copilot Chat
* Path/URL: https://api.githubcopilot.com/chat/completions
* Model:
* Model: gpt-4
* Label: Copilot (GitHub)

---
Expand All @@ -72,7 +72,7 @@
-- Testing chattr
* Provider: OpenAI - GitHub Copilot Chat
* Path/URL: https://api.githubcopilot.com/chat/completions
* Model:
* Model: gpt-4
* Label: Copilot (GitHub)
v Connection with GitHub Copilot cofirmed
|--Prompt: TEST
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-chattr-use.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ test_that("Request submission works", {
test_that("Menu works", {
skip_on_cran()
withr::with_envvar(
new = c("OPENAI_API_KEY" = "test"),
new = c("OPENAI_API_KEY" = "test", "DATABRICKS_TOKEN" = NA),
{
local_mocked_bindings(
menu = function(...) {
return(1)
}
)
print(ch_get_ymls(menu = TRUE) )
expect_true(
ch_get_ymls(menu = TRUE) %in% c("gpt35", "gpt4")
ch_get_ymls(menu = TRUE) %in% c("gpt35", "gpt4", "gpt4o")
)
}
)
Expand Down
Loading