community[patch]: Add test case for MoonshotChat (#24960)

Add test case for `MoonshotChat`.
This commit is contained in:
ZhangShenao 2024-08-02 21:37:31 +08:00 committed by GitHub
parent c65e48996c
commit 71c0564c9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,36 @@
"""Test Moonshot Chat Model."""
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
from langchain_community.chat_models.moonshot import MoonshotChat
def test_default_call() -> None:
"""Test default model call."""
chat = MoonshotChat() # type: ignore[call-arg]
response = chat.invoke([HumanMessage(content="How are you?")])
assert isinstance(response, BaseMessage)
assert isinstance(response.content, str)
def test_model() -> None:
"""Test model kwarg works."""
chat = MoonshotChat(model="moonshot-v1-32k") # type: ignore[call-arg]
response = chat.invoke([HumanMessage(content="How are you?")])
assert isinstance(response, BaseMessage)
assert isinstance(response.content, str)
def test_multiple_history() -> None:
"""Tests multiple history works."""
chat = MoonshotChat() # type: ignore[call-arg]
response = chat.invoke(
[
HumanMessage(content="How are you?"),
AIMessage(content="I'm fine, and you?"),
HumanMessage(content="Not bad!"),
]
)
assert isinstance(response, BaseMessage)
assert isinstance(response.content, str)

View File

@ -1,4 +1,4 @@
"""Test Alibaba Tongyi Chat Model."""
"""Test ZhipuAI Chat Model."""
from langchain_core.callbacks import CallbackManager
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage