Python: fix(google-ai): skip api_key check when use_vertexai is True#13607
Open
giulio-leone wants to merge 1 commit intomicrosoft:mainfrom
Open
Python: fix(google-ai): skip api_key check when use_vertexai is True#13607giulio-leone wants to merge 1 commit intomicrosoft:mainfrom
giulio-leone wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
The api_key validation in GoogleAIChatCompletion, GoogleAITextCompletion, and GoogleAITextEmbedding ran unconditionally, blocking Vertex AI users who authenticate via Application Default Credentials (no API key). Guard the check with `not google_ai_settings.use_vertexai` so that only non-Vertex AI configurations require an API key. The error message already reads 'when use_vertexai is False', matching the new condition. Fixes microsoft#13483
27f8e4d to
ce250e0
Compare
Author
|
Friendly ping — CI is green and this is ready for review. Happy to address any feedback. Thanks! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13483
Motivation and Context
When
use_vertexai=True, users authenticate via Application Default Credentials (ADC) and don't need an API key. However, the initialization check forapi_keyruns unconditionally, blocking Vertex AI users with:Description
Guard the
api_keyvalidation withnot google_ai_settings.use_vertexaiin all three Google AI service classes:GoogleAIChatCompletionGoogleAITextCompletionGoogleAITextEmbeddingThe error message already reads "when use_vertexai is False", so the condition now matches the intent.
Before / After
Contribution Checklist