Home / Function/ _embedding_factory() — langchain Function Reference

_embedding_factory() — langchain Function Reference

Architecture documentation for the _embedding_factory() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  44470235_396e_663e_a023_314dec5f45e6["_embedding_factory()"]
  8775603f_4af4_2e2d_459a_8e3ad12aaec4["base.py"]
  44470235_396e_663e_a023_314dec5f45e6 -->|defined in| 8775603f_4af4_2e2d_459a_8e3ad12aaec4
  style 44470235_396e_663e_a023_314dec5f45e6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/evaluation/embedding_distance/base.py lines 50–72

def _embedding_factory() -> Embeddings:
    """Create an `Embeddings` object.

    Returns:
        The created `Embeddings` object.
    """
    # Here for backwards compatibility.
    # Generally, we do not want to be seeing imports from langchain community
    # or partner packages in langchain.
    try:
        from langchain_openai import OpenAIEmbeddings
    except ImportError:
        try:
            from langchain_community.embeddings.openai import (
                OpenAIEmbeddings,
            )
        except ImportError as e:
            msg = (
                "Could not import OpenAIEmbeddings. Please install the "
                "OpenAIEmbeddings package using `pip install langchain-openai`."
            )
            raise ImportError(msg) from e
    return OpenAIEmbeddings()

Domain

Subdomains

Frequently Asked Questions

What does _embedding_factory() do?
_embedding_factory() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/embedding_distance/base.py.
Where is _embedding_factory() defined?
_embedding_factory() is defined in libs/langchain/langchain_classic/evaluation/embedding_distance/base.py at line 50.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free