-
Notifications
You must be signed in to change notification settings - Fork 109
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 token handling for Azure #234
base: main
Are you sure you want to change the base?
updates token handling for Azure #234
Conversation
Thank you for taking the time to contribute! Some comments:
|
Tony and I talked about the PR a few days ago (we work together). This does better handling of the Azure token. Before we were generating a token way too often. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Let me know if you have any questions.
}, | ||
error = function(e) NULL | ||
) | ||
token <- retrieve_azure_token_object() %>% suppressMessages() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we no longer have magrittr dependency so we are using base pipe
@@ -10,6 +10,9 @@ | |||
)) | |||
} | |||
|
|||
require("Microsoft365R") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to refactor this so that this is an optional dependency. Most packages won't need it since most don't use Azure OpenAI.
#' a function that determines the appropriate directory to cache a token | ||
#' @export | ||
gptstudio_cache_directory = function(){ | ||
rappdirs::user_data_dir(appname = glue::glue("gptstudio"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we switch this to tools::R_user_dir()
?
@@ -110,31 +110,33 @@ query_api_azure_openai <- | |||
retrieve_azure_token <- function() { | |||
rlang::check_installed("AzureRMR") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swap out for Microsoft365R?
|
||
invisible(token$token$credentials$access_token) | ||
client <- Microsoft365R:::do_login(tenant = Sys.getenv("AZURE_OPENAI_TENANT_ID"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRAN might yell about us depending on a hidden function, but I'm not sure what the rules are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On these situations I would prefer to reverse-engineer the function to have a local version instead of a dependency. But the level of effort required varies between cases
Thanks @JamesHWade , I'll move away from this one then |
Description of changes
This pull request addresses token management for Azure Open AI tokens. The token is saved to a gptstudio specific directory and ensures that tokens are properly refreshed as needed.