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/unit_tests/llms/test_watsonxllm.py

56 lines
1.6 KiB
Python

"""Test WatsonxLLM API wrapper."""
from langchain_community.llms import WatsonxLLM
def test_initialize_watsonxllm_bad_path_without_url() -> None:
try:
WatsonxLLM(
model_id="google/flan-ul2",
)
except ValueError as e:
assert "WATSONX_URL" in e.__str__()
def test_initialize_watsonxllm_cloud_bad_path() -> None:
try:
WatsonxLLM(model_id="google/flan-ul2", url="https://us-south.ml.cloud.ibm.com")
except ValueError as e:
assert "WATSONX_APIKEY" in e.__str__()
def test_initialize_watsonxllm_cpd_bad_path_without_all() -> None:
try:
WatsonxLLM(
model_id="google/flan-ul2",
url="https://cpd-zen.apps.cpd48.cp.fyre.ibm.com",
)
except ValueError as e:
assert (
"WATSONX_APIKEY" in e.__str__()
and "WATSONX_PASSWORD" in e.__str__()
and "WATSONX_TOKEN" in e.__str__()
)
def test_initialize_watsonxllm_cpd_bad_path_password_without_username() -> None:
try:
WatsonxLLM(
model_id="google/flan-ul2",
url="https://cpd-zen.apps.cpd48.cp.fyre.ibm.com",
password="test_password",
)
except ValueError as e:
assert "WATSONX_USERNAME" in e.__str__()
def test_initialize_watsonxllm_cpd_bad_path_apikey_without_username() -> None:
try:
WatsonxLLM(
model_id="google/flan-ul2",
url="https://cpd-zen.apps.cpd48.cp.fyre.ibm.com",
apikey="test_apikey",
)
except ValueError as e:
assert "WATSONX_USERNAME" in e.__str__()