feat(genai/embeddings): migrate lower dimension embeddings to genai - #14512
feat(genai/embeddings): migrate lower dimension embeddings to genai#14512XrossFox wants to merge 2 commits into
Conversation
Migrates the sample for generating multimodal embeddings with lower dimensionality to use the new `google-genai` SDK and adds the corresponding test.
There was a problem hiding this comment.
Code Review
This pull request introduces a new script generate_embeddings_with_lower_dimension.py along with its corresponding test to demonstrate generating multimodal embeddings with custom lower dimensionality using the google-genai SDK. The review feedback highlights two critical runtime issues in the new script: the genai.Client should be initialized with vertexai=True instead of enterprise=True, and the text part should be created by instantiating Part directly rather than using the non-existent from_text classmethod.
| client = genai.Client( | ||
| enterprise=True, | ||
| project=PROJECT_ID, | ||
| location=LOCATION_ID, | ||
| ) |
There was a problem hiding this comment.
The google-genai SDK uses the vertexai parameter to initialize the client for Vertex AI, rather than enterprise. Using enterprise=True will result in a TypeError at runtime.
| client = genai.Client( | |
| enterprise=True, | |
| project=PROJECT_ID, | |
| location=LOCATION_ID, | |
| ) | |
| client = genai.Client( | |
| vertexai=True, | |
| project=PROJECT_ID, | |
| location=LOCATION_ID, | |
| ) |
There was a problem hiding this comment.
It does not, tested locally.
| mime_type="image/png", | ||
| ) | ||
|
|
||
| text_part = genai.types.Part.from_text(text=CONTEXTUAL_TEXT) |
There was a problem hiding this comment.
There was a problem hiding this comment.
Tested locally, it does.


Description
Migrates the sample for generating multimodal embeddings with lower dimensionality to use the new
google-genaiSDK and adds thecorresponding test.
Fixes b/546128628
Checklist
Testing
Compliance & Style
Post-Approval Actions