langchain-ai/langchain-google

First Batch of results in `VertexAIEmbeddings` does not respect the dimensions passed for embedding

Open

#1,089 opened on Aug 22, 2025

 (2 comments) (0 reactions) (0 assignees)Python (461 forks)auto 404
help wantedinvestigatevertexai

Repository metrics

Stars
 (392 stars)
PR merge metrics
 (PR metrics pending)

Description

https://github.com/langchain-ai/langchain-google/blob/a2a05f568ddc5a823617e70d5b379187938893f4/libs/vertexai/langchain_google_vertexai/embeddings.py#L367

In here, it seems that the dimensions is not passed for the first batch to be processed based on the embedding dimensions passed by the client. This Creates a bug when custom dimensions needs to be embedded from VertexAI Embeddings (eg. 768 dimension embedding from gemini-embedding-001)

The fix is simple. pass in the dimensions forward:

first_result = self._get_embeddings_with_retry(
                        first_batch, embeddings_type, dimensions
                    )

Contributor guide