-
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
Open
Madzionator
wants to merge
11
commits into
main
Choose a base branch
from
feat/vertex
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 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 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
Some comments aren't visible on the classic Files Changed page.
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
| 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
| 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
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 |
|---|---|---|
|
|
@@ -23,8 +23,10 @@ public static class Anthropic | |
|
|
||
| public static class Gemini | ||
| { | ||
| public const string Gemini2_5Pro = "gemini-2.5-pro"; | ||
Madzionator marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public const string Gemini2_5Flash = "gemini-2.5-flash"; | ||
| public const string Gemini2_0Flash = "gemini-2.0-flash"; | ||
| public const string Imagen4_0_FastGenerate = "imagen-4.0-fast-generate-001"; | ||
| } | ||
|
|
||
| public static class Xai | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to extend it with Grok 4 - 4.2 models |
||
|
|
@@ -49,6 +51,14 @@ public static class Ollama | |
| public const string Gemma3_4b = "gemma3:4b"; | ||
| } | ||
|
|
||
| public static class Vertex | ||
| { | ||
| public const string Gemini2_5Pro = "google/gemini-2.5-pro"; | ||
| public const string Gemini2_5Flash = "google/gemini-2.5-flash"; | ||
| public const string Veo2_0_Generate = "google/veo-2.0-generate-001"; | ||
| public const string Imagen4_0_Generate = "google/imagen-4.0-generate-001"; | ||
| } | ||
|
|
||
| public static class Local | ||
| { | ||
| // Gemma | ||
|
|
||
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.