-
Notifications
You must be signed in to change notification settings - Fork 792
Open
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Today embed_content does behave differently depending on how the client was created (with API_KEY or vertex ai) for gemini-embedding-2-preview". The issue for vertex AI is we cannot get embeddings of multiple texts with a single requests, we need a request per text.
Is it a behavior you're planning to keep, or do you plan to update at some point?
import os
import google.auth
import vertexai
from google import genai
contents = ["The dog is cute", "The cat is cute"]
api_client = genai.Client(api_key="XXXXX")
embeddings = api_client.models.embed_content(model="gemini-embedding-2-preview", contents=contents).embeddings
assert len(embeddings) == 2
_, project = google.auth.default()
vertexai.init(project=project, location="us-central1")
vertex_ai_client = genai.Client(vertexai=True, project=project, location="us-central1")
embeddings = vertex_ai_client.models.embed_content(model="gemini-embedding-2-preview", contents=contents).embeddings
assert len(embeddings) == 1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.