test_base.py — langchain Source File
Architecture documentation for test_base.py, a python file in the langchain codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f12b7d6e_0611_80f0_7c4e_4e59bae044a5["test_base.py"] 3888b2bf_bffe_7c16_770f_a406d400119c["importlib"] f12b7d6e_0611_80f0_7c4e_4e59bae044a5 --> 3888b2bf_bffe_7c16_770f_a406d400119c 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] f12b7d6e_0611_80f0_7c4e_4e59bae044a5 --> 120e2591_3e15_b895_72b6_cb26195e40a6 bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3["langchain_core.embeddings"] f12b7d6e_0611_80f0_7c4e_4e59bae044a5 --> bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3 85b83517_db5f_3066_2c59_8cb8da70b0cf["langchain.embeddings.base"] f12b7d6e_0611_80f0_7c4e_4e59bae044a5 --> 85b83517_db5f_3066_2c59_8cb8da70b0cf style f12b7d6e_0611_80f0_7c4e_4e59bae044a5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test embeddings base module."""
import importlib
import pytest
from langchain_core.embeddings import Embeddings
from langchain.embeddings.base import _BUILTIN_PROVIDERS, init_embeddings
@pytest.mark.parametrize(
("provider", "model"),
[
("openai", "text-embedding-3-large"),
("google_vertexai", "text-embedding-gecko@003"),
("bedrock", "amazon.titan-embed-text-v1"),
("cohere", "embed-english-v2.0"),
],
)
async def test_init_embedding_model(provider: str, model: str) -> None:
package = _BUILTIN_PROVIDERS[provider][0]
try:
importlib.import_module(package)
except ImportError:
pytest.skip(f"Package {package} is not installed")
model_colon = init_embeddings(f"{provider}:{model}")
assert isinstance(model_colon, Embeddings)
model_explicit = init_embeddings(
model=model,
provider=provider,
)
assert isinstance(model_explicit, Embeddings)
text = "Hello world"
embedding_colon = await model_colon.aembed_query(text)
assert isinstance(embedding_colon, list)
assert all(isinstance(x, float) for x in embedding_colon)
embedding_explicit = await model_explicit.aembed_query(text)
assert isinstance(embedding_explicit, list)
assert all(isinstance(x, float) for x in embedding_explicit)
Domain
Subdomains
Functions
Dependencies
- importlib
- langchain.embeddings.base
- langchain_core.embeddings
- pytest
Source
Frequently Asked Questions
What does test_base.py do?
test_base.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_base.py?
test_base.py defines 1 function(s): test_init_embedding_model.
What does test_base.py depend on?
test_base.py imports 4 module(s): importlib, langchain.embeddings.base, langchain_core.embeddings, pytest.
Where is test_base.py in the architecture?
test_base.py is located at libs/langchain_v1/tests/integration_tests/embeddings/test_base.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain_v1/tests/integration_tests/embeddings).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free