Home / File/ embeddings.py — langchain Source File

embeddings.py — langchain Source File

Architecture documentation for embeddings.py, a python file in the langchain codebase. 8 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  8ce40ba1_d898_f955_9c48_a4761d500f9f["embeddings.py"]
  9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c
  cccbe73e_4644_7211_4d55_e8fb133a8014["abc"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> cccbe73e_4644_7211_4d55_e8fb133a8014
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  6ebcaae2_3bc1_badf_b751_e164ff2776c4["unittest"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> 6ebcaae2_3bc1_badf_b751_e164ff2776c4
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> 120e2591_3e15_b895_72b6_cb26195e40a6
  bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3["langchain_core.embeddings"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  86e12e47_abd3_7376_ceed_f0108db0965a["langchain_tests.base"]
  8ce40ba1_d898_f955_9c48_a4761d500f9f --> 86e12e47_abd3_7376_ceed_f0108db0965a
  style 8ce40ba1_d898_f955_9c48_a4761d500f9f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Embeddings unit tests."""

import os
from abc import abstractmethod
from typing import Any
from unittest import mock

import pytest
from langchain_core.embeddings import Embeddings
from pydantic import SecretStr

from langchain_tests.base import BaseStandardTests


class EmbeddingsTests(BaseStandardTests):
    """Embeddings tests base class."""

    @property
    @abstractmethod
    def embeddings_class(self) -> type[Embeddings]:
        """Embeddings class."""

    @property
    def embedding_model_params(self) -> dict[str, Any]:
        """Embeddings model parameters."""
        return {}

    @pytest.fixture
    def model(self) -> Embeddings:
        """Embeddings model fixture."""
        return self.embeddings_class(**self.embedding_model_params)


class EmbeddingsUnitTests(EmbeddingsTests):
    """Base class for embeddings unit tests.

    Test subclasses must implement the `embeddings_class` property to specify the
    embeddings model to be tested. You can also override the
    `embedding_model_params` property to specify initialization parameters.

    ```python
    from typing import Type

    from langchain_tests.unit_tests import EmbeddingsUnitTests
    from my_package.embeddings import MyEmbeddingsModel


    class TestMyEmbeddingsModelUnit(EmbeddingsUnitTests):
        @property
        def embeddings_class(self) -> Type[MyEmbeddingsModel]:
            # Return the embeddings model class to test here
            return MyEmbeddingsModel

        @property
        def embedding_model_params(self) -> dict:
            # Return initialization parameters for the model.
            return {"model": "model-001"}
    ```
    !!! note
        API references for individual test methods include troubleshooting tips.
// ... (78 more lines)

Subdomains

Dependencies

  • abc
  • langchain_core.embeddings
  • langchain_tests.base
  • os
  • pydantic
  • pytest
  • typing
  • unittest

Frequently Asked Questions

What does embeddings.py do?
embeddings.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What does embeddings.py depend on?
embeddings.py imports 8 module(s): abc, langchain_core.embeddings, langchain_tests.base, os, pydantic, pytest, typing, unittest.
Where is embeddings.py in the architecture?
embeddings.py is located at libs/standard-tests/langchain_tests/unit_tests/embeddings.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/standard-tests/langchain_tests/unit_tests).

Analyze Your Own Codebase

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

Try Supermodel Free