-
Notifications
You must be signed in to change notification settings - Fork 39
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
Determine whether we really need to support API keys and Entra ID tokens simultaneously in chat_azure()
#274
Comments
Unfortunately, the only way we can authenticate given our internal configuration is both. Most other Azure OpenAI users will not require this, but I'd really like to still be able to use the package internally. The reason we require both is that the token is coming from a different RG than the Azure AI Foundry instance. This is not a configuration I have the power to change. |
It's a bit surprising that this wouldn't be mentioned in their docs, but I'm happy to accommodate here, and I suspect you won't be alone in having less-than-optimal Azure resource group arrangements! |
@JamesHWade Yes, because I thought you'd probably be using the |
@SokolovAnatoliy has a better handle on this than me. I'll defer to him. I'm using his contribution to our internal package anyway. |
@atheriel - sorry I replied in a different thread here #262 (comment). Could you take a look at that line specifically. |
(Moved here from #262.) I don't see this error with either pattern? > chat <- chat_azure(
+ endpoint = "https://test.openai.azure.com/",
+ deployment_id = "gpt-4o-mini",
+ credentials = function() "aaron"
+ )
Using api_version = "2024-10-21".
> chat <- chat_azure(
+ endpoint = "https://test.openai.azure.com/",
+ deployment_id = "gpt-4o-mini",
+ token = NULL,
+ credentials = function() "aaron"
+ )
Using api_version = "2024-10-21".
Warning message:
The `token` argument of `chat_azure()` is deprecated as of ellmer 0.1.1.
ℹ Support for the static `token` argument (which quickly expires) will be dropped in next release.
Use ambient Azure credentials instead, or pass an explicit `credentials` argument.
> chat <- chat_azure(
+ endpoint = "[https://test.openai.azure.com/](vscode-file://vscode-app/usr/share/positron/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#)",
+ deployment_id = "gpt-4o-mini",
+ token = NULL,
+ api_key = "secret",
+ credentials = function() "aaron"
+ )
Using api_version = "2024-10-21". |
Here's what I'm seeing: chat <- ellmer::chat_azure(
endpoint = "https://test.openai.azure.com/",
deployment_id = "model",
api_key = "abc123",
credentials = function() "james",
)
#> Using api_version = "2024-10-21".
#> Error in `ellmer::chat_azure()`:
#> ! Exactly one of `token` or `credentials` must be supplied. Created on 2025-01-28 with reprex v2.1.0 |
@atheriel I see the problem. The current version of ellmer that we are using is 0.1.0.9000, while your lifecycle function is looking for 0.1.1.
So, for us, it always fails. I don't see the 0.1.1 yet? But I also think the approach will fail if you provide a token instead of a credentials function. Consider the scenarios below. Scenario 1:
This works, since the token is a function, and not NULL, which is the reason you aren't seeing this in your test case. Scenario 2:
This fails, since Scenario 3:
This will fail, because the argument Scenario 4:
This will work. This is why, for you, it works without a token or credentials function in your test. I think maybe there is a better way to check this? It seems to be very reliant on the |
Edit: missed the one James provided. |
I see it now. There's some interaction with |
This was somehow masked in my local testing due to `devtools::load_all()` but reported in #274. This commit makes the exclusive check before the deprecation check, which resolves the issue. Signed-off-by: Aaron Jacobs <[email protected]>
Fix in #284, I think. |
This was somehow masked in my local testing due to `devtools::load_all()` but reported in #274. This commit makes the exclusive check before the deprecation check, which resolves the issue. Signed-off-by: Aaron Jacobs <[email protected]>
@atheriel this is working, thanks a lot for all your quick help! |
@SokolovAnatoliy reported in #248 (comment) that they use both API keys and Entra ID for authentication, so I ensured this was possible in #256.
But Azure's docs on this are unequivocal that one or the other is required, but not both:
We should sort out which party is incorrect. The internals of
chat_azure()
would be much simpler if only one or the other is required.The text was updated successfully, but these errors were encountered: