-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
fix load custom google credentials #388
Conversation
WalkthroughThe recent changes enhance the credential management and project ID handling within the Google Vertex AI integration. By transitioning from a static project ID approach to leveraging service account credentials, the implementation gains flexibility and security. The test code has also been simplified, improving readability by streamlining the configuration process. Overall, these updates create a more robust and maintainable framework for interacting with the Google AI Platform. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant VertexAIProvider
participant GoogleCredential
participant ServiceAccountCredential
User->>VertexAIProvider: Initialize
VertexAIProvider->>GoogleCredential: Get Application Default
GoogleCredential->>ServiceAccountCredential: Retrieve Credential
VertexAIProvider->>User: Configuration Ready
User->>VertexAIProvider: Generate Image
VertexAIProvider->>ServiceAccountCredential: Use ProjectId
ServiceAccountCredential-->>VertexAIProvider: Return ProjectId
VertexAIProvider->>User: Image Generated
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- src/Providers/Google.VertexAI/src/VertexAIChatModel.cs (2 hunks)
- src/Providers/Google.VertexAI/src/VertexAIConfiguration.cs (2 hunks)
- src/Providers/Google.VertexAI/src/VertexAITextToImageModel.cs (2 hunks)
- src/Providers/Google.VertexAI/test/VertexAITest.cs (1 hunks)
Additional comments not posted (5)
src/Providers/Google.VertexAI/src/VertexAIConfiguration.cs (1)
1-2
: LGTM! But verify the usage of the new property in the codebase.The changes enhance credential management by leveraging Google Cloud's credential system. Ensure that all references to the old
ProjectId
property are updated to use the newGoogleCredential
property.Also applies to: 11-11
Verification successful
LGTM! The
GoogleCredential
property is correctly used across the codebase.The changes enhance credential management by leveraging Google Cloud's credential system. All references to the old
ProjectId
property have been updated to use the newGoogleCredential
property appropriately.
VertexAIConfiguration.cs
: Declares and initializesGoogleCredential
.VertexAITextToImageModel.cs
: UsesGoogleCredential
to accessProjectId
.VertexAIChatModel.cs
: UsesGoogleCredential
to accessProjectId
.VertexAITest.cs
: Contains commented-out code referencingGoogleCredential
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new `GoogleCredential` property in the codebase. # Test: Search for the usage of `GoogleCredential`. Expect: Only occurances of the new property. rg --type cs -A 5 $'GoogleCredential'Length of output: 2634
src/Providers/Google.VertexAI/test/VertexAITest.cs (1)
7-7
: LGTM! But verify the test coverage.The changes simplify the test methods, improving readability and maintainability. Ensure that the tests still cover all necessary scenarios.
Also applies to: 13-25, 27-33, 40-50
Verification successful
LGTM! But verify the test coverage.
The changes simplify the test methods, improving readability and maintainability. The test methods
Chat
andTextToImage
cover essential functionalities of theVertexAIProvider
, ensuring adequate test coverage.
Chat
: Tests theGenerateAsync
function of theGemini15ProChatModel
.TextToImage
: Tests theGenerateImageAsync
function of theVertexAITextToImageModel
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the test coverage after simplifying the test methods. # Test: Run the tests to ensure they cover all necessary scenarios. dotnet testLength of output: 87
Script:
#!/bin/bash # Search for test methods in the VertexAITest.cs file to verify their coverage ast-grep --lang csharp --pattern 'public void $_()' src/Providers/Google.VertexAI/test/VertexAITest.csLength of output: 104
Script:
#!/bin/bash # Search for test methods in the VertexAITest.cs file using common test method attributes ast-grep --lang csharp --pattern '[TestMethod] public void $_()' src/Providers/Google.VertexAI/test/VertexAITest.cs ast-grep --lang csharp --pattern '[Fact] public void $_()' src/Providers/Google.VertexAI/test/VertexAITest.csLength of output: 229
Script:
#!/bin/bash # Search for test methods in the VertexAITest.cs file using ripgrep rg 'public void' -A 3 src/Providers/Google.VertexAI/test/VertexAITest.csLength of output: 74
Script:
#!/bin/bash # Display the entire content of the VertexAITest.cs file to inspect its structure and identify test methods cat src/Providers/Google.VertexAI/test/VertexAITest.csLength of output: 1974
src/Providers/Google.VertexAI/src/VertexAITextToImageModel.cs (1)
1-2
: LGTM! But verify the updated logic.The changes improve the flexibility and security of the authentication process. Ensure that the project ID is correctly retrieved from the
serviceAccountCredential
.Also applies to: 18-22
Verification successful
LGTM! But verify the updated logic.
The changes improve the flexibility and security of the authentication process. The project ID is correctly retrieved from the
serviceAccountCredential
in bothVertexAITextToImageModel
andVertexAIChatModel
.
VertexAITextToImageModel.cs
:
- Line 1:
var serviceAccountCredential = Provider.Configuration.GoogleCredential?.UnderlyingCredential as ServiceAccountCredential;
- Line 5:
serviceAccountCredential?.ProjectId
VertexAIChatModel.cs
:
- Line 1:
var serviceAccountCredential = Provider.Configuration.GoogleCredential?.UnderlyingCredential as ServiceAccountCredential;
- Line 4:
serviceAccountCredential?.ProjectId
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the updated logic in the `GenerateImageAsync` method. # Test: Search for the usage of `serviceAccountCredential` to ensure the project ID is correctly retrieved. rg --type cs -A 5 $'serviceAccountCredential'Length of output: 2244
src/Providers/Google.VertexAI/src/VertexAIChatModel.cs (2)
1-1
: Import for OAuth2 is necessary.The addition of
Google.Apis.Auth.OAuth2
is required for handlingServiceAccountCredential
.
42-45
: Verify initialization and type casting ofUnderlyingCredential
.Ensure that
Provider.Configuration.GoogleCredential
is properly initialized and thatUnderlyingCredential
is indeed aServiceAccountCredential
.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor