2024-01-26 20:57:26 +00:00
|
|
|
"""Test Baichuan Text Embedding."""
|
|
|
|
from langchain_community.embeddings.baichuan import BaichuanTextEmbeddings
|
|
|
|
|
|
|
|
|
|
|
|
def test_baichuan_embedding_documents() -> None:
|
|
|
|
"""Test Baichuan Text Embedding for documents."""
|
|
|
|
documents = ["今天天气不错", "今天阳光灿烂"]
|
2024-05-13 18:55:07 +00:00
|
|
|
embedding = BaichuanTextEmbeddings() # type: ignore[call-arg]
|
2024-01-26 20:57:26 +00:00
|
|
|
output = embedding.embed_documents(documents)
|
2024-02-05 19:22:06 +00:00
|
|
|
assert len(output) == 2 # type: ignore[arg-type]
|
|
|
|
assert len(output[0]) == 1024 # type: ignore[index]
|
2024-01-26 20:57:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_baichuan_embedding_query() -> None:
|
|
|
|
"""Test Baichuan Text Embedding for query."""
|
|
|
|
document = "所有的小学生都会学过只因兔同笼问题。"
|
2024-05-13 18:55:07 +00:00
|
|
|
embedding = BaichuanTextEmbeddings() # type: ignore[call-arg]
|
2024-01-26 20:57:26 +00:00
|
|
|
output = embedding.embed_query(document)
|
2024-02-05 19:22:06 +00:00
|
|
|
assert len(output) == 1024 # type: ignore[arg-type]
|