langchain/libs/partners/ai21/tests/integration_tests/test_embeddings.py
Asaf Joseph Gardin 4d7f6fa968
ai21[patch]: AI21 Labs Batch Support in Embeddings (#18633)
Description: Added support for batching when using AI21 Embeddings model
Twitter handle: https://github.com/AI21Labs

---------

Co-authored-by: Asaf Gardin <asafg@ai21.com>
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-03-14 23:10:23 +00:00

38 lines
1.2 KiB
Python

"""Test AI21 embeddings."""
from langchain_ai21.embeddings import AI21Embeddings
def test_langchain_ai21_embedding_documents() -> None:
"""Test AI21 embeddings."""
documents = ["foo bar"]
embedding = AI21Embeddings()
output = embedding.embed_documents(documents)
assert len(output) == 1
assert len(output[0]) > 0
def test_langchain_ai21_embedding_query() -> None:
"""Test AI21 embeddings."""
document = "foo bar"
embedding = AI21Embeddings()
output = embedding.embed_query(document)
assert len(output) > 0
def test_langchain_ai21_embedding_documents__with_explicit_chunk_size() -> None:
"""Test AI21 embeddings with chunk size passed as an argument."""
documents = ["foo", "bar"]
embedding = AI21Embeddings()
output = embedding.embed_documents(documents, batch_size=1)
assert len(output) == 2
assert len(output[0]) > 0
def test_langchain_ai21_embedding_query__with_explicit_chunk_size() -> None:
"""Test AI21 embeddings with chunk size passed as an argument."""
documents = "foo bar"
embedding = AI21Embeddings()
output = embedding.embed_query(documents, batch_size=1)
assert len(output) > 0