2023-07-14 05:58:22 +00:00
|
|
|
"""Test Tongyi API wrapper."""
|
2023-11-21 16:35:29 +00:00
|
|
|
from langchain_core.outputs import LLMResult
|
2023-11-20 21:09:30 +00:00
|
|
|
|
2023-12-11 21:53:30 +00:00
|
|
|
from langchain_community.llms.tongyi import Tongyi
|
2023-07-14 05:58:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_tongyi_call() -> None:
|
|
|
|
"""Test valid call to tongyi."""
|
|
|
|
llm = Tongyi()
|
|
|
|
output = llm("who are you")
|
|
|
|
assert isinstance(output, str)
|
|
|
|
|
|
|
|
|
|
|
|
def test_tongyi_generate() -> None:
|
|
|
|
"""Test valid call to tongyi."""
|
|
|
|
llm = Tongyi()
|
|
|
|
output = llm.generate(["who are you"])
|
|
|
|
assert isinstance(output, LLMResult)
|
|
|
|
assert isinstance(output.generations, list)
|
|
|
|
|
|
|
|
|
|
|
|
def test_tongyi_generate_stream() -> None:
|
|
|
|
"""Test valid call to tongyi."""
|
|
|
|
llm = Tongyi(streaming=True)
|
|
|
|
output = llm.generate(["who are you"])
|
|
|
|
print(output)
|
|
|
|
assert isinstance(output, LLMResult)
|
|
|
|
assert isinstance(output.generations, list)
|