-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
The current implementation of the VertexAIEmbeddings
class, found in the provided code snippet, uses the deprecated vertexai
SDK for Google's Generative AI models.
To ensure compatibility, access to the latest features, and adherence to Google's recommended library usage, this component should be migrated to use the google-genai
Python SDK.
The specific parts of the code that use the legacy SDK are the imports and calls related to TextEmbeddingModel
and TextEmbeddingInput
:
try:
from vertexai.language_models import TextEmbeddingInput, TextEmbeddingModel
except (ImportError, AttributeError):
TextEmbeddingModel = TextEmbeddingInput = None # type: ignore[misc, assignment]
# ... inside VertexAIEmbeddings __init__
self.model = TextEmbeddingModel.from_pretrained(model)
# ... inside VertexAIEmbeddings _embed_query
inputs: list[str | TextEmbeddingInput] = [
TextEmbeddingInput(text, task_type)
]
embeddings = self.model.get_embeddings(inputs, **kwargs)
Action Items:
- Update the dependency to use
google-genai
instead of or alongsidevertexai
. - Modify the
VertexAIEmbeddings
class to use the corresponding methods and classes fromgoogle-genai
(e.g.,client.models.generate_embeddings
). - Ensure the migration follows the official guide provided by Google for the SDK deprecation.
Reference:
The migration guide for the Vertex AI SDK deprecation can be found here:
https://cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk.md
from vertexai.language_models import TextEmbeddingInput, TextEmbeddingModel |
Metadata
Metadata
Assignees
Labels
No labels