langchain/libs/community/tests/unit_tests/embeddings/test_baichuan.py
Eugene Yurtsev 6e57aa7c36
community[patch]: Remove usage of @root_validator(allow_reuse=True) (#25235)
Remove usage of @root_validator(allow_reuse=True)
2024-08-09 10:57:42 -04:00

19 lines
562 B
Python

from typing import cast
from langchain_core.pydantic_v1 import SecretStr
from langchain_community.embeddings import BaichuanTextEmbeddings
def test_sparkllm_initialization_by_alias() -> None:
# Effective initialization
embeddings = BaichuanTextEmbeddings( # type: ignore[call-arg]
model="embedding_model",
api_key="your-api-key", # type: ignore[arg-type]
)
assert embeddings.model_name == "embedding_model"
assert (
cast(SecretStr, embeddings.baichuan_api_key).get_secret_value()
== "your-api-key"
)