You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/libs/community/tests/integration_tests/embeddings/test_sparkllm.py

36 lines
1.7 KiB
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""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]