Skip to content

chore: Google Vertex AI support#47

Merged
mattinannt merged 16 commits intomainfrom
chore/google-vertex-ai-support
Mar 11, 2026
Merged

chore: Google Vertex AI support#47
mattinannt merged 16 commits intomainfrom
chore/google-vertex-ai-support

Conversation

@xernobyl
Copy link
Contributor

@xernobyl xernobyl commented Mar 9, 2026

What does this PR do?

Adds Google Vertex AI as an embedding provider (google-vertex) alongside openai and google (AI Studio).

  • New provider: EMBEDDING_PROVIDER=google-vertex; uses Application Default Credentials (no API key).
  • New config: EMBEDDING_GOOGLE_CLOUD_PROJECT, EMBEDDING_GOOGLE_CLOUD_LOCATION (with fallbacks to GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION).
  • Embedding client factory: New internal/service/embedding_client_factory.go centralizes client creation and provider validation; API and backfill-embeddings use it.
  • Google AI: googleai.NewVertexClient(ctx, project, location, opts...) for Vertex backend; existing AI Studio client unchanged.
  • Docs: .env.example and OpenAPI updated for google-vertex and the new env vars.

No API contract changes; existing embedding and semantic-search endpoints work with the new provider when configured.

How should this be tested?

  • Run make tests and make tests-coverage (embedding client factory, config, googleai client tests).
  • Run make build, make fmt, make lint.
  • Manual: set EMBEDDING_PROVIDER=google-vertex, EMBEDDING_GOOGLE_CLOUD_PROJECT, EMBEDDING_GOOGLE_CLOUD_LOCATION, EMBEDDING_MODEL; ensure ADC (e.g. gcloud auth application-default login); start API, create a feedback record, confirm embedding job and semantic search work.

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Repository Guidelines
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran make build
  • Ran make tests (integration tests in tests/)
  • Ran make fmt and make lint; no new warnings
  • Removed debug prints / temporary logging
  • Merged the latest changes from main onto my branch with git pull origin main
  • If database schema changed: added migration in migrations/ with goose annotations and ran make migrate-validate

Appreciated

  • If API changed: added or updated OpenAPI spec and ran contract tests (make tests or API contract workflow)
  • If API behavior changed: added request/response examples or Swagger UI screenshots to this PR
  • Updated docs in docs/ if changes were necessary
  • Ran make tests-coverage for meaningful logic changes

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

✱ Stainless preview builds

This PR will update the hub SDKs with the following commit message.

chore: Google Vertex AI support
hub-openapi studio · code

Your SDK built successfully.
generate ✅

hub-typescript studio · code

Your SDK built successfully.
generate ✅build ✅lint ✅test ✅


This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-03-11 09:17:34 UTC

@xernobyl
Copy link
Contributor Author

xernobyl commented Mar 9, 2026

@coderabbitai can you review please?

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

@xernobyl Sure! I'll start reviewing the PR right away.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Walkthrough

This pull request refactors the embedding client architecture to support multiple providers through a centralized, provider-agnostic factory pattern. It adds support for Google Vertex AI as an embedding provider alongside existing OpenAI and Google AI Studio options. The changes include a new embedding client factory module, configuration enhancements for Google Cloud project and location settings, a new Vertex AI client constructor, and updated validation logic across initialization code. Configuration guidance and documentation are updated to reflect the newly supported providers. Tests are added for new configuration paths and factory logic.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature being added: Google Vertex AI support as a new embedding provider.
Description check ✅ Passed The PR description covers the main changes, new configuration, implementation details, testing instructions, and includes a filled-out 'How should this be tested?' section with specific steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/config/config_test.go`:
- Around line 272-326: Add tests that assert EMBEDDING_GOOGLE_CLOUD_* env vars
take precedence over GOOGLE_CLOUD_* when both are set: create two new tests
(e.g., TestLoad_EmbeddingGoogleCloudProject_precedence and
TestLoad_EmbeddingGoogleCloudLocation_precedence) that call t.Setenv for
API_KEY, set EMBEDDING_GOOGLE_CLOUD_PROJECT="explicit-project" and
GOOGLE_CLOUD_PROJECT="fallback-project", call Load(), and assert
cfg.EmbeddingGoogleCloudProject == "explicit-project"; do the same pattern for
EMBEDDING_GOOGLE_CLOUD_LOCATION vs GOOGLE_CLOUD_LOCATION asserting
cfg.EmbeddingGoogleCloudLocation == "explicit-location".

In `@internal/googleai/client.go`:
- Around line 81-102: NewVertexClient should validate its inputs before calling
genai.NewClient: check that the project string is not empty and return a
descriptive error (e.g., "empty project") if it is, and also check that the
location string is not empty and return a descriptive error (e.g., "empty
location") if it is; perform these checks at the start of NewVertexClient
(before genai.NewClient is invoked) so the function fails fast with consistent
messages while leaving the rest of the function (client creation, applying opts,
returning client) unchanged.

In `@internal/service/embedding_client_factory_test.go`:
- Around line 11-112: Add a test case in TestNewEmbeddingClient that ensures
provider name normalization is exercised for the google-vertex provider: create
an EmbeddingClientConfig with Provider set to a mixed-case and whitespace
variant (e.g. " Google-Vertex ") and the same fields as the existing
EmbeddingProviderGoogleVertex case, then assert the same error behavior
(ErrEmbeddingVertexConfig) or success as appropriate; this verifies
NewEmbeddingClient and any provider-trimming/lowercasing logic correctly
normalizes the provider string (referencing NewEmbeddingClient,
EmbeddingClientConfig, and EmbeddingProviderGoogleVertex).

In `@internal/service/embedding_client_factory.go`:
- Around line 41-109: The provider capability matrix is duplicated across
NewEmbeddingClient, ProviderRequiresAPIKey, ProviderRequiresVertexConfig, and
SupportedEmbeddingProviders causing inconsistent checks; consolidate into a
single source of truth by introducing a registry (map/struct) keyed by provider
that declares capabilities (requiresAPIKey, requiresVertexConfig, model support,
factory function) and then refactor NewEmbeddingClient to consult that registry
to build clients, implement a new exported ValidateEmbeddingClientConfig(cfg
EmbeddingClientConfig) (or similar) that uses the same registry to validate
preconditions, and replace the existing ProviderRequiresAPIKey,
ProviderRequiresVertexConfig, and SupportedEmbeddingProviders callers to use the
registry/ValidateEmbeddingClientConfig so all provider metadata lives in one
place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 09c86b9a-f9ce-48a6-abf6-16cbb485453f

📥 Commits

Reviewing files that changed from the base of the PR and between 0949ba1 and e271bdc.

📒 Files selected for processing (13)
  • .env.example
  • cmd/api/app.go
  • cmd/backfill-embeddings/main.go
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/googleai/client.go
  • internal/googleai/client_test.go
  • internal/service/embedding_client_factory.go
  • internal/service/embedding_client_factory_test.go
  • internal/service/embedding_provider.go
  • internal/service/embedding_provider_test.go
  • internal/service/webhook_sender.go
  • openapi.yaml

@xernobyl xernobyl marked this pull request as ready for review March 9, 2026 23:02
Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xernobyl Thanks a lot for the PR :-) Looks great!

@mattinannt mattinannt added this pull request to the merge queue Mar 11, 2026
Merged via the queue into main with commit 8e6255c Mar 11, 2026
9 checks passed
@mattinannt mattinannt deleted the chore/google-vertex-ai-support branch March 11, 2026 09:16
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