You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current method for passing a token to the ProviderAzure class passes the token as a string. Once the chat object is created, there is no way to update the token string if the token expires. The consequence is that the entire chat must be re-created, losing all context.
I am suggesting a change to address this issue by passing a token object from the AzureAuth package. The token has built in validate and refresh methods. The chat can now check if the token is valid, and if that fails, attempt to refresh the token.
I wrote up these changes in a pull request.
I also noticed that the approach to validate the arguments to the ProviderAzure class uses the S7::as_class function. The issue is that there is not a way to validate an R6 class (what the AzureAuth package returns for the token) using the S7::as_class function.
I added a workaround in the pull request like this, but I don't love it because it will make the elmer package depend on the AzureAuth package. I used a blank token to retrieve the class name to ensure that the class "AzureToken" was not hard coded.
prop_azure_token <- function(allow_null = FALSE) {
force(allow_null)
## The call to AzureAuth ensures that the class name of the Azure Token does not change
class_name = AzureAuth::AzureToken$self$classname
## The returned token object is R6 - not currently supported by the S7::as_class()
## so I made a new S3 class to use validator
AzureToken_class <- new_S3_class(class_name)
new_property(
class = if (allow_null) NULL | AzureToken_class else AzureToken_class,
validator = function(value) {
if (allow_null && is.null(value)) {
return()
}
if (!inherits(value, class_name)) {
paste0("must be an object of class <", class_name, ">, not ", obj_type_friendly(value), ".")
}
}
)
}
I did not add the dependency in the pull request, because maybe there is a better way to do this? I added this code to the pull request, because without it, the change would not work, but any fixes would be very welcome.
The text was updated successfully, but these errors were encountered:
The current method for passing a token to the
ProviderAzure
class passes the token as a string. Once the chat object is created, there is no way to update the token string if the token expires. The consequence is that the entire chat must be re-created, losing all context.I am suggesting a change to address this issue by passing a token object from the
AzureAuth
package. The token has built in validate and refresh methods. The chat can now check if the token is valid, and if that fails, attempt to refresh the token.I wrote up these changes in a pull request.
I also noticed that the approach to validate the arguments to the
ProviderAzure
class uses theS7::as_class
function. The issue is that there is not a way to validate an R6 class (what theAzureAuth
package returns for the token) using theS7::as_class
function.I added a workaround in the pull request like this, but I don't love it because it will make the
elmer
package depend on theAzureAuth
package. I used a blank token to retrieve the class name to ensure that the class "AzureToken" was not hard coded.I did not add the dependency in the pull request, because maybe there is a better way to do this? I added this code to the pull request, because without it, the change would not work, but any fixes would be very welcome.
The text was updated successfully, but these errors were encountered: