Skip to content

Add google_genai as supported provider for embeddings factory in init_embeddings. #34386

@Christophe-Lamarche-Cossette

Description

Checked other resources

  • This is a feature request, not a bug report or usage question.
  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-community package.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-cli
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-perplexity
  • langchain-prompty
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Feature Description

Google Gen AI is not supported as a provider in init_embeddings.

Only the Google VertexAI VertexAIEmbedding is used within the factory function for the embeddings. The _init_chat_model already has Google Gen AI has a supported provider.

(In this release note)[https://github.com/langchain-ai/langchain-google/discussions/1422], it is mentioned that the google_gen_ai is the new provider that langchain recommended when using Google services.

Use Case

I am using Google as my service provider and I used the API key as my certification method and I was refused to use google_genai for my embedding while my chat models use Google Generative ai.

From the documentation, I understand that the Google Generative AI will be the new recommended package for Google services, so I just want to make sure that the migration works for embeddings as well.

Proposed Solution

This could be done by adding:

    "google_genai": "langchain_google_genai",

in the mapping (dictionnary) of _SUPPORTED_PROVIDERS in langchain/embeddings/base.py.

if provider == "google_genai":
        from langchain_google_genai import GoogleGenerativeAIEmbeddings
        
        return GoogleGenerativeAIEmbeddings(model=model_name, **kwargs)

in the init_embeddings function in langchain/embeddings/base.py.

Alternatives Considered

I could use Google VertexAI, but the documentation recommend Google Generative AI.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestRequest for an enhancement / additional functionalitylangchain`langchain` package issues & PRs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions