langchain/libs/community/tests/integration_tests/embeddings/test_hunyuan.py
Lvlvko 5c17a4ace9
community: support Hunyuan Embedding (#23160)
## description

- I refactor `Chathunyuan` using tencentcloud sdk because I found the
original one can't work in my application
- I add `HunyuanEmbeddings` using tencentcloud sdk
- Both of them are extend the basic class of langchain. I have fully
tested them in my application

## Dependencies
- tencentcloud-sdk-python

---------

Co-authored-by: centonhuang <centonhuang@tencent.com>
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-12-16 19:27:19 +00:00

26 lines
706 B
Python

from langchain_community.embeddings.hunyuan import HunyuanEmbeddings
def test_embedding_query() -> None:
query = "foo"
embedding = HunyuanEmbeddings()
output = embedding.embed_query(query)
assert len(output) == 1024
def test_embedding_document() -> None:
documents = ["foo bar"]
embedding = HunyuanEmbeddings()
output = embedding.embed_documents(documents)
assert len(output) == 1
assert len(output[0]) == 1024
def test_embedding_documents() -> None:
documents = ["foo", "bar"]
embedding = HunyuanEmbeddings()
output = embedding.embed_documents(documents)
assert len(output) == 2
assert len(output[0]) == 1024
assert len(output[1]) == 1024