2023-12-05 03:42:15 +00:00
|
|
|
"""Test Bookend AI embeddings."""
|
2023-12-11 21:53:30 +00:00
|
|
|
from langchain_community.embeddings.bookend import BookendEmbeddings
|
2023-12-05 03:42:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_bookend_embedding_documents() -> None:
|
|
|
|
"""Test Bookend AI embeddings for documents."""
|
|
|
|
documents = ["foo bar", "bar foo"]
|
|
|
|
embedding = BookendEmbeddings(
|
|
|
|
domain="<bookend_domain>",
|
|
|
|
api_token="<bookend_api_token>",
|
|
|
|
model_id="<bookend_embeddings_model_id>",
|
|
|
|
)
|
|
|
|
output = embedding.embed_documents(documents)
|
|
|
|
assert len(output) == 2
|
|
|
|
assert len(output[0]) == 768
|
|
|
|
|
|
|
|
|
|
|
|
def test_bookend_embedding_query() -> None:
|
|
|
|
"""Test Bookend AI embeddings for query."""
|
|
|
|
document = "foo bar"
|
|
|
|
embedding = BookendEmbeddings(
|
|
|
|
domain="<bookend_domain>",
|
|
|
|
api_token="<bookend_api_token>",
|
|
|
|
model_id="<bookend_embeddings_model_id>",
|
|
|
|
)
|
|
|
|
output = embedding.embed_query(document)
|
|
|
|
assert len(output) == 768
|