2023-11-29 21:16:42 +00:00
|
|
|
"""Test volc engine maas LLM model."""
|
|
|
|
|
|
|
|
from typing import Generator
|
|
|
|
|
2023-12-06 19:45:05 +00:00
|
|
|
from langchain_core.outputs import LLMResult
|
|
|
|
|
2023-12-11 21:53:30 +00:00
|
|
|
from langchain_community.llms.volcengine_maas import VolcEngineMaasLLM
|
2023-11-29 21:16:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_default_call() -> None:
|
|
|
|
"""Test valid call to volc engine."""
|
|
|
|
llm = VolcEngineMaasLLM()
|
|
|
|
output = llm("tell me a joke")
|
|
|
|
assert isinstance(output, str)
|
|
|
|
|
|
|
|
|
|
|
|
def test_generate() -> None:
|
|
|
|
"""Test valid call to volc engine."""
|
|
|
|
llm = VolcEngineMaasLLM()
|
|
|
|
output = llm.generate(["tell me a joke"])
|
|
|
|
assert isinstance(output, LLMResult)
|
|
|
|
assert isinstance(output.generations, list)
|
|
|
|
|
|
|
|
|
|
|
|
def test_generate_stream() -> None:
|
|
|
|
"""Test valid call to volc engine."""
|
|
|
|
llm = VolcEngineMaasLLM(streaming=True)
|
|
|
|
output = llm.stream("tell me a joke")
|
|
|
|
assert isinstance(output, Generator)
|