-
-
Notifications
You must be signed in to change notification settings - Fork 148
[Platform][VertexAI] Add support for API key authentication #1139
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
base: main
Are you sure you want to change the base?
Conversation
|
Please add tests |
Sure. Before I spend more time on tests, can you review that the approach/solution is correct? I'm relatively new to the symfony/ai project and not sure how other Bridges handle this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. WDYT @chr-hertel ?
@nicodemuz can you please check if it is also supported for Gemini. This should also be configurable via the AiBundle config
@OskarStark You mean to configure whether the key should be sent via a query parameter or the headers? For Gemini, I think the API key is sent via HTTP headers: ai/src/platform/src/Bridge/Gemini/Gemini/ModelClient.php Lines 81 to 86 in 5b89765
|
Thanks for double checking |
| ======================================== | ||
| 1. Application Default Credentials (ADC) | ||
| ======================================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ======================================== | |
| 1. Application Default Credentials (ADC) | |
| ======================================== | |
| Application Default Credentials (ADC) | |
| ------------------------------------- |
Same for the other headlines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OskarStark I'm trying to fix the tests, and there's one test failing with: Is it trying to run code from some other repo/branch? Since it's referring to |
|
Tests still needed |
Co-authored-by: Oskar Stark <oskarstark@googlemail.com>
| # Vertex AI | ||
| GOOGLE_CLOUD_LOCATION=global | ||
| GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT | ||
| GOOGLE_CLOUD_VERTEX_API_KEY= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| GOOGLE_CLOUD_VERTEX_API_KEY= | |
| GOOGLE_CLOUD_API_KEY= |
in the whole PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't google cloud have hundreds of APIs that can be accessed with a product specific API key? This API key is for the key that can be created at https://console.cloud.google.com/vertex-ai/studio/settings/api-keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm you might be right 🤔
|
|
||
| require_once __DIR__.'/bootstrap.php'; | ||
|
|
||
| $platform = PlatformFactory::create(env('GOOGLE_CLOUD_LOCATION'), env('GOOGLE_CLOUD_PROJECT'), env('GOOGLE_CLOUD_VERTEX_API_KEY'), httpClient: adc_aware_http_client()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this still uses the adc_aware_http_client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed! 👍
|
It looks like your committer email is not associated with your GitHub account |
OskarStark
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
| # Vertex AI | ||
| GOOGLE_CLOUD_LOCATION=global | ||
| GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT | ||
| GOOGLE_CLOUD_VERTEX_API_KEY= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm you might be right 🤔
| if (null !== $this->apiKey) { | ||
| $url .= '?key='.$this->apiKey; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big fan of string-based concatenation when it comes to ? and & - might be brittle when extending later
can we use the query part of the HttpClient's request method here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| if (null !== $this->apiKey) { | ||
| $url .= '?key='.$this->apiKey; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
chr-hertel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we def need this - thanks @nicodemuz!
only minor comments but broken pipeline
Any ideas about the broken pipeline? See my comment here: |
Will this prevent from the PR getting merged? I remember getting a lot of spam after entering my email address in public repos. |

Vertex AI supports multiple methods of authentication. This PR adds support for API keys.