VertexAI: Add service account key authentication support#532
Open
multiplegeorges wants to merge 5 commits intocrmne:mainfrom
Open
VertexAI: Add service account key authentication support#532multiplegeorges wants to merge 5 commits intocrmne:mainfrom
multiplegeorges wants to merge 5 commits intocrmne:mainfrom
Conversation
…ation logic - Added `vertexai_service_account_key` to the configuration requirements for Vertex AI. - Updated the authorization method to use service account credentials if the key is provided, otherwise defaults to application default credentials.
Author
|
Looks like #520 is making related changes to the Vertex provider, so probably a good idea to review both in tandem/together. |
|
+1, could use this! |
|
+1 |
Contributor
|
in the mean time something like this can be done: credentials = Rails.application.credentials.dig(:google_cloud, :credentials)
if credentials.present?
# Write credentials to temp file for Google Cloud SDK authentication
require "tempfile"
require "json"
credentials_file = Tempfile.new([ "vertex_ai_credentials", ".json" ])
credentials_file.write(credentials.to_json)
credentials_file.close
# Set environment variable for Google Cloud SDK
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_file.path
# Clean up temp file on exit
at_exit { credentials_file.unlink }
# Configure Vertex AI
config.vertexai_project_id = Rails.application.credentials.dig(:google_cloud, :project_id)
config.vertexai_location = Rails.application.credentials.dig(:google_cloud, :location)
end |
We initially named this configuration `_hash` but was later updated to `_key`
…ion-key Change service account hash to key for authorizer
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.
What this does
This pull request adds support for authenticating to Google Vertex AI using a Service Account JSON key in addition to the existing Application Default Credentials (ADC) method. It updates both the documentation and the implementation to allow users to provide a Service Account key for Vertex AI authentication, improving flexibility and compatibility with Google Cloud best practices.
Vertex AI Authentication Enhancements:
vertexai_service_account_keyto theRubyLLMconfiguration, allowing users to specify a Service Account JSON key as a string for Vertex AI authentication. [1] [2] [3]Documentation Updates:
vertexai_service_account_keyoption, how authentication works, and Google Cloud’s recommendations regarding API keys and Service Accounts.Test/Spec Configuration:
vertexai_service_account_key, ensuring test environments can utilize the new authentication method.Type of change
Scope check
Quality check
overcommit --installand all hooks passbundle exec rake vcr:record[provider_name]bundle exec rspecmodels.json,aliases.json)API changes
Related issues
None.