Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
SokolovAnatoliy committed Dec 17, 2024
1 parent 5624b4f commit 6488ac8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion R/cache.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' a function that determines the appropriate directory to cache a token
#' @export
gptstudio_cache_directory = function(){
gptstudio_cache_directory <- function() {
tools::R_user_dir(package = "gptstudio")
}
14 changes: 7 additions & 7 deletions R/service-azure_openai.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,23 @@ retrieve_azure_token_object <- function() {
rlang::check_installed("AzureGraph")

## Set this so that get_graph_login properly caches
azure_data_env = Sys.getenv("R_AZURE_DATA_DIR")
azure_data_env <- Sys.getenv("R_AZURE_DATA_DIR")

Sys.setenv("R_AZURE_DATA_DIR" = gptstudio_cache_directory())

login <- try(AzureGraph::get_graph_login(tenant = Sys.getenv("AZURE_OPENAI_TENANT_ID"),
app = Sys.getenv("AZURE_OPENAI_CLIENT_ID"),
scopes = NULL,
refresh = FALSE),
silent=TRUE) |>
silent = TRUE) |>
suppressMessages()

if(inherits(login, "try-error")) {
if (inherits(login, "try-error")) {

if(!dir.exists(gptstudio_cache_directory())) dir.create(gptstudio_cache_directory()) |> suppressWarnings()
if (!dir.exists(gptstudio_cache_directory())) {
dir.create(gptstudio_cache_directory()) |>
suppressWarnings()
}


login <- AzureGraph::create_graph_login(tenant = Sys.getenv("AZURE_OPENAI_TENANT_ID"),
Expand Down Expand Up @@ -173,8 +176,5 @@ stream_azure_openai <- function(messages = list(list(role = "user", content = "h
},
round = "line"
)

invisible(response)
}


0 comments on commit 6488ac8

Please sign in to comment.