mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
d6ef5fe86a
**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>
38 lines
1.1 KiB
Python
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
|