fix(Connectors.Google): use embedContent API for gemini-embedding models - #14266
Open
Diwakar Ray Yadav (Diwak4r) wants to merge 1 commit into
Open
fix(Connectors.Google): use embedContent API for gemini-embedding models#14266Diwakar Ray Yadav (Diwak4r) wants to merge 1 commit into
Diwakar Ray Yadav (Diwak4r) wants to merge 1 commit into
Conversation
Author
|
Just verifying this is still in the review queue. All checks green, branch is mergeable. Happy to address any feedback. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
VertexAIEmbeddingGeneratorhardcodes the:predictendpoint for every model. That method is no longer served forgemini-embedding-*models, so using e.g.gemini-embedding-2fails with400 FAILED_PRECONDITION.This PR routes embedding requests by model family:
gemini-embedding-*models → the:batchEmbedContentsmethod, with therequests[].content.parts[].textpayload shape and theembeddings[].valuesresponse shape.text-embedding-*,multimodalembedding, etc.) → unchanged:predictpath with the existinginstancespayload.Why this shape
batchEmbedContentsis the batched equivalent ofembedContent— it maps 1:1 onto the client's existing behavior of embedding a list of strings in a single HTTP call, and returnsembeddingsin input order.outputDimensionalityis forwarded exactly as before.Tests
Added to
VertexAIClientEmbeddingsGenerationTests(red → green):ShouldUseBatchEmbedContentsEndpointForGeminiEmbeddingModelAsync— asserts:batchEmbedContentsendpoint +requests[].content.parts[].textbody forgemini-embedding-2.ShouldUsePredictEndpointForLegacyEmbeddingModelAsync— asserts:predictendpoint +instancesbody fortext-embedding-004(regression guard).ShouldReturnValidEmbeddingsResponseForGeminiEmbeddingModelAsync— parses a newvertex_embed_content_response.jsonfixture into vectors.Full
Connectors.Google.UnitTestssuite: 437 passed, 0 failed.Fixes #14265