-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a more flexible credentials mechanism for chat_azure().
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 `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 <[email protected]>
- Loading branch information
Showing
4 changed files
with
136 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Azure request headers are generated correctly | ||
|
||
Code | ||
req | ||
Message | ||
<httr2_request> | ||
POST | ||
https://ai-hwickhamai260967855527.openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2024-06-01 | ||
Headers: | ||
* api-key: '<REDACTED>' | ||
Body: json encoded data | ||
Policies: | ||
* retry_max_tries: 2 | ||
* retry_on_failure: FALSE | ||
* error_body: a function | ||
|
||
--- | ||
|
||
Code | ||
req | ||
Message | ||
<httr2_request> | ||
POST | ||
https://ai-hwickhamai260967855527.openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2024-06-01 | ||
Headers: | ||
* Authorization: '<REDACTED>' | ||
Body: json encoded data | ||
Policies: | ||
* retry_max_tries: 2 | ||
* retry_on_failure: FALSE | ||
* error_body: a function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters