Skip to content

VertexAIEmbeddings does not accept a taskType field #9371

@knotekbr

Description

@knotekbr

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

import { VertexAIEmbeddings } from "@langchain/google-vertexai";

const embeddings = new VertexAIEmbeddings({
  location: "us-central1",
  authOptions: {
    projectId: "my-project"
  },
  model: "text-embedding-005",
  outputDimensionality: 768,
});

const vector = await embeddings.embedQuery("What color is my favorite shirt?");

Error Message and Stack Trace (if applicable)

n/a

Description

  • I'm trying to use @langchain/google-vertexai to embed both corpus documents and subsequent user queries
  • I expect to be able to pass an embedding taskType to the VertexAIEmbeddings constructor
  • As far as I can tell, I'm not able to specify a taskType value anywhere

I've never opened an issue before, so I apologize in advance if this doesn't belong here. If that's the case, I'm happy to submit it elsewhere.

Per the Vertex AI documentation, I'm expecting to be able to provide a task type when generating embeddings. It looks like this field is supported by the GoogleGenerativeAIEmbeddings class present in @langchain/google-genai (python docs, TypeScript source), but is missing from VertexAIEmbeddings.

System Info

  • Platform: Windows
  • Node version: 22.12.0
  • Yarn version: 4.3.1
  • yarn info langchain:
    └─ langchain@npm:1.0.3
     ├─ Instances: 1
     ├─ Version: 1.0.3
     │
     └─ Dependencies
        ├─ @langchain/langgraph-checkpoint@npm:^1.0.0 → npm:1.0.0
        ├─ @langchain/langgraph@npm:^1.0.0 → npm:1.0.1
        ├─ langsmith@npm:~0.3.74 → npm:0.3.78
        ├─ uuid@npm:^10.0.0 → npm:10.0.0
        └─ zod@npm:^3.25.76 || ^4 → npm:4.1.12
    
  • yarn info @langchain/google-vertexai:
    └─ @langchain/google-vertexai@npm:1.0.0
     ├─ Version: 1.0.0
     │ 
     └─ Dependencies
        └─ @langchain/google-gauth@npm:^1.0.0 → npm:1.0.0
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions