langchain/libs/partners/together/tests/integration_tests/test_embeddings.py
Hassan El Mghari d6ef5fe86a
together: add chat models, use openai base (#21337)
**Description:** Adding chat completions to the Together AI package,
which is our most popular API. Also staying backwards compatible with
the old API so folks can continue to use the completions API as well.
Also moved the embedding API to use the OpenAI library to standardize it
further.

**Twitter handle:** @nutlope

- [x] **Add tests and docs**: If you're adding a new integration, please
include
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
2024-05-06 17:47:06 -07:00

38 lines
1.1 KiB
Python

"""Test Together AI embeddings."""
from langchain_together import TogetherEmbeddings
def test_langchain_together_embed_documents() -> None:
"""Test Together AI embeddings."""
documents = ["foo bar", "bar foo"]
embedding = TogetherEmbeddings()
output = embedding.embed_documents(documents)
assert len(output) == 2
assert len(output[0]) > 0
def test_langchain_together_embed_query() -> None:
"""Test Together AI embeddings."""
query = "foo bar"
embedding = TogetherEmbeddings()
output = embedding.embed_query(query)
assert len(output) > 0
async def test_langchain_together_aembed_documents() -> None:
"""Test Together AI embeddings asynchronous."""
documents = ["foo bar", "bar foo"]
embedding = TogetherEmbeddings()
output = await embedding.aembed_documents(documents)
assert len(output) == 2
assert len(output[0]) > 0
async def test_langchain_together_aembed_query() -> None:
"""Test Together AI embeddings asynchronous."""
query = "foo bar"
embedding = TogetherEmbeddings()
output = await embedding.aembed_query(query)
assert len(output) > 0