Add a more flexible credentials mechanism for chat_azure()#248
Conversation
hadley
left a comment
There was a problem hiding this comment.
Could you add a news bullet please?
In lieu of adding support for Azure authentication packages directly, this commit adds a mechanism that at least allows them to be used and refreshed manually (see tidyverse#195 and tidyverse#196): a `credentials` argument that takes a function, similar to what we have for `chat_cortex()` today. The `credentials` function is called on every request to Azure, making it possible to refresh tokens that have expired prior to their use. I also did some internal refactoring of the `ProviderAzure` class in the process, and removed the need to set `api_key = ""` to use token-based authentication. Unit tests are included. Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
6247cfc to
d1a08ad
Compare
|
Done. |
|
Thanks! |
|
Hi @atheriel , My apologies on the delay testing this pr. I tested out this approach and wanted to make a couple of comments. I was able to get the credential function working successfully by writing a custom function that takes into account the configuration that we are using. In our configuration, we need both an I would think that perhaps the Was there a specific usage pattern that made you add this restriction to the pr? In regards to the I guess you could find the token in the chat environment and update it, but that doesn't seem like the right approach? Maybe it would be best to just remove the This way, the The request could be structured like this, which would add the So in my case, I would use a custom function like I like this, since I would not need to deal with an Then my chat object could be create like this for Dow users. What do you think about this, and is this how you intended for users to use the |
|
Thanks for the testing!
No, I just misunderstood Azure's documentation. It makes it seem like you use either API keys or Entra ID auth, but not both. I can certainly restore the previous treatment of API keys.
No, I largely left this intact because I didn't want to deprecate an parameter so soon in |
|
@atheriel no concerns from my side. |
This implements the suggestion from testers of tidyverse#248, who rightly pointed out that my assumption that API keys and Entra ID credentials are mutually exclusive was incorrect. Unit tests are included. Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
In lieu of adding support for Azure authentication packages directly, this commit adds a mechanism that at least allows them to be used and refreshed manually (see #195 and #196): a
credentialsargument that takes a function, similar to what we have forchat_cortex()today.The
credentialsfunction is called on every request to Azure, making it possible to refresh tokens that have expired prior to their use.I also did some internal refactoring of the
ProviderAzureclass in the process, and removed the need to setapi_key = ""to use token-based authentication.Unit tests are included.