Embeddings integration tests¶
EmbeddingsIntegrationTests
¶
Bases: EmbeddingsTests
Base class for embeddings integration 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.
from typing import Type
from langchain_tests.integration_tests import EmbeddingsIntegrationTests
from my_package.embeddings import MyEmbeddingsModel
class TestMyEmbeddingsModelIntegration(EmbeddingsIntegrationTests):
@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.
| METHOD | DESCRIPTION |
|---|---|
test_no_overrides_DO_NOT_OVERRIDE |
Test that no standard tests are overridden. |
model |
Embeddings model fixture. |
test_embed_query |
Test embedding a string query. |
test_embed_documents |
Test embedding a list of strings. |
test_aembed_query |
Test embedding a string query async. |
test_aembed_documents |
Test embedding a list of strings async. |
test_no_overrides_DO_NOT_OVERRIDE
¶
Test that no standard tests are overridden.
test_embed_query
¶
test_embed_query(model: Embeddings) -> None
Test embedding a string query.
Troubleshooting
If this test fails, check that:
- The model will generate a list of floats when calling
.embed_queryon a string. - The length of the list is consistent across different inputs.
test_embed_documents
¶
test_embed_documents(model: Embeddings) -> None
Test embedding a list of strings.
Troubleshooting
If this test fails, check that:
- The model will generate a list of lists of floats when calling
embed_documentson a list of strings. - The length of each list is the same.
test_aembed_query
async
¶
test_aembed_query(model: Embeddings) -> None
Test embedding a string query async.
Troubleshooting
If this test fails, check that:
- The model will generate a list of floats when calling
aembed_queryon a string. - The length of the list is consistent across different inputs.
test_aembed_documents
async
¶
test_aembed_documents(model: Embeddings) -> None
Test embedding a list of strings async.
Troubleshooting
If this test fails, check that:
- The model will generate a list of lists of floats when calling
aembed_documentson a list of strings. - The length of each list is the same.