2022-11-08 14:24:23 +00:00
|
|
|
"""Test NLPCloud API wrapper."""
|
|
|
|
|
2022-12-13 14:46:01 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from langchain.llms.loading import load_llm
|
2022-11-08 14:24:23 +00:00
|
|
|
from langchain.llms.nlpcloud import NLPCloud
|
2022-12-13 14:46:01 +00:00
|
|
|
from tests.integration_tests.llms.utils import assert_llm_equality
|
2022-11-08 14:24:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_nlpcloud_call() -> None:
|
|
|
|
"""Test valid call to nlpcloud."""
|
|
|
|
llm = NLPCloud(max_length=10)
|
|
|
|
output = llm("Say foo:")
|
|
|
|
assert isinstance(output, str)
|
2022-12-13 14:46:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_saving_loading_llm(tmp_path: Path) -> None:
|
|
|
|
"""Test saving/loading an NLPCloud LLM."""
|
|
|
|
llm = NLPCloud(max_length=10)
|
|
|
|
llm.save(file_path=tmp_path / "nlpcloud.yaml")
|
|
|
|
loaded_llm = load_llm(tmp_path / "nlpcloud.yaml")
|
|
|
|
assert_llm_equality(llm, loaded_llm)
|