-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Vertex AI integration #128
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c4175e2
Add Vertex AI backend support
Madzionator 34f7ed5
Add shared token cache and refresh lock for Vertex token
Madzionator 05f7f5f
Add Vertex AI backend support and UI
Madzionator cec95a6
Fix vertex file send for pdf files (without ocr)
Madzionator af17c31
fix: Use model backend when creating BackendParams
Madzionator d7e2a5f
final improvements
Madzionator 8c26bf9
Add Vertex Imagen image generation service
Madzionator 217732e
Refactor: replace hardcoded image gen model constants with central Mo…
Madzionator b93669e
Add MCP for vertex
Madzionator 3895334
Merge branch 'main' into feat/vertex
Madzionator fdbcb84
versioning
Madzionator aba6c2e
Add new cloud models and XAI reasoning support
Madzionator d24f51a
Merge branch 'main' into feat/vertex
Madzionator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| using Examples.Utils; | ||
| using MaIN.Core.Hub; | ||
| using MaIN.Domain.Configuration.BackendInferenceParams; | ||
| using MaIN.Domain.Models; | ||
|
|
||
| namespace Examples.Chat; | ||
|
|
||
| public class ChatExampleVertex : IExample | ||
| { | ||
| public async Task Start() | ||
| { | ||
| VertexExample.Setup(); //We need to provide Google service account config | ||
| Console.WriteLine("(Vertex AI) ChatExample is running!"); | ||
|
|
||
| await AIHub.Chat() | ||
| .WithModel(Models.Vertex.Gemini2_5Pro) | ||
| .WithMessage("Is the killer whale the smartest animal?") | ||
| .WithInferenceParams(new VertexInferenceParams | ||
| { | ||
| Location = "europe-central2" | ||
| }) | ||
| .CompleteAsync(interactive: true); | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| using MaIN.Core; | ||
| using MaIN.Domain.Configuration; | ||
| using MaIN.Domain.Configuration.Vertex; | ||
|
|
||
| namespace Examples.Utils; | ||
|
|
||
| public class VertexExample | ||
| { | ||
| public static void Setup() | ||
| { | ||
| MaINBootstrapper.Initialize(configureSettings: options => | ||
| { | ||
| options.BackendType = BackendType.Vertex; | ||
| options.GoogleServiceAccountAuth = new GoogleServiceAccountConfig | ||
| { | ||
| ProjectId = "<YOUR_GCP_PROJECT_ID>", | ||
| ClientEmail = "<YOUR_SERVICE_ACCOUNT_EMAIL>", | ||
| PrivateKey = @"<YOUR_PRIVATE_KEY>" | ||
| }; | ||
| }); | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # 0.10.4 release | ||
|
|
||
| Adds Google Vertex AI as a backend with authentication, MCP support, and new models including image generation, along with UI configuration and example usage. |
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
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
18 changes: 18 additions & 0 deletions
18
src/MaIN.Domain/Configuration/BackendInferenceParams/VertexInferenceParams.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| using MaIN.Domain.Entities; | ||
| using Grammar = MaIN.Domain.Models.Grammar; | ||
|
|
||
| namespace MaIN.Domain.Configuration.BackendInferenceParams; | ||
|
|
||
| public class VertexInferenceParams : IBackendInferenceParams | ||
| { | ||
| public BackendType Backend => BackendType.Vertex; | ||
|
|
||
| public string Location { get; init; } = "us-central1"; | ||
|
|
||
| public float? Temperature { get; init; } | ||
| public int? MaxTokens { get; init; } | ||
| public float? TopP { get; init; } | ||
| public string[]? StopSequences { get; init; } | ||
| public Grammar? Grammar { get; set; } | ||
| public Dictionary<string, object>? AdditionalParams { get; init; } | ||
| } |
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
9 changes: 9 additions & 0 deletions
9
src/MaIN.Domain/Configuration/Vertex/GoogleServiceAccountConfig.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| namespace MaIN.Domain.Configuration.Vertex; | ||
|
|
||
| public class GoogleServiceAccountConfig | ||
| { | ||
| public required string ProjectId { get; init; } | ||
| public required string ClientEmail { get; init; } | ||
| public required string PrivateKey { get; init; } | ||
| public string TokenUri { get; init; } = "https://oauth2.googleapis.com/token"; | ||
| } |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.