Skip to content
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

Add support for storing Google Cloud key as ENV var directly #19

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

weilandia
Copy link
Contributor

This is a little verbose, but was in a hurry and wanted the fewest diffs.

Being able to use the key directly is much simpler for multi env production apps so we don't have to deal with files, especially when we only use Google Cloud for Vertex.

@gbaptista
Copy link
Owner

@weilandia, thanks for opening the pull request!

Yeah, I got it. So, I'm thinking about the name of the key. json_key works but can be a bit confusing. I was thinking about keeping the semantics of file and using file_contents so it can match the already existing file_path:

client = Gemini.new(
  credentials: {
    service: 'vertex-ai-api',
    file_path: 'google-credentials.json',
    region: 'us-east4'
  },
  options: { model: 'gemini-pro', server_sent_events: true }
)

So, it would be:

client = Gemini.new(
  credentials: {
    service: 'vertex-ai-api',
    file_contents: File.read('google-credentials.json'),
    region: 'us-east4'
  },
  options: { model: 'gemini-pro', server_sent_events: true }
)
client = Gemini.new(
  credentials: {
    service: 'vertex-ai-api',
    file_contents: ENV['GOOGLE_CREDENTIALS_FILE_CONTENTS'],
    region: 'us-east4'
  },
  options: { model: 'gemini-pro', server_sent_events: true }
)

How do you feel about it?

@weilandia
Copy link
Contributor Author

Sounds good, I updated the PR.

@gbaptista
Copy link
Owner

@weilandia Awesome, thanks for your contribution!

@gbaptista gbaptista merged commit 2276b6e into gbaptista:main Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants