langchain/libs/community/tests/integration_tests/embeddings/test_sparkllm.py
Eugene Yurtsev 25fbe356b4
community[patch]: upgrade to recent version of mypy (#21616)
This PR upgrades community to a recent version of mypy. It inserts type:
ignore on all existing failures.
2024-05-13 14:55:07 -04:00

36 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Test SparkLLM Text Embedding."""
from langchain_community.embeddings.sparkllm import SparkLLMTextEmbeddings
def test_baichuan_embedding_documents() -> None:
"""Test SparkLLM Text Embedding for documents."""
documents = [
"iFLYTEK is a well-known intelligent speech and artificial intelligence "
"publicly listed company in the Asia-Pacific Region. Since its establishment,"
"the company is devoted to cornerstone technological research "
"in speech and languages, natural language understanding, machine learning,"
"machine reasoning, adaptive learning, "
"and has maintained the world-leading position in those "
"domains. The company actively promotes the development of A.I. "
"products and their sector-based "
"applications, with visions of enabling machines to listen and speak, "
"understand and think, "
"creating a better world with artificial intelligence."
]
embedding = SparkLLMTextEmbeddings() # type: ignore[call-arg]
output = embedding.embed_documents(documents)
assert len(output) == 1 # type: ignore[arg-type]
assert len(output[0]) == 2560 # type: ignore[index]
def test_baichuan_embedding_query() -> None:
"""Test SparkLLM Text Embedding for query."""
document = (
"iFLYTEK Open Platform was launched in 2010 by iFLYTEK as Chinas "
"first Artificial Intelligence open platform for Mobile Internet "
"and intelligent hardware developers"
)
embedding = SparkLLMTextEmbeddings() # type: ignore[call-arg]
output = embedding.embed_query(document)
assert len(output) == 2560 # type: ignore[arg-type]