mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
community[patch]: Optimize test case for MoonshotChat
(#25050)
Optimize test case for `MoonshotChat`. Use standard ChatModelIntegrationTests.
This commit is contained in:
parent
cea3f72485
commit
cda79dbb6c
@ -1,36 +1,23 @@
|
|||||||
"""Test Moonshot Chat Model."""
|
"""Test Moonshot Chat Model."""
|
||||||
|
|
||||||
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
|
from typing import Type
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from langchain_core.language_models import BaseChatModel
|
||||||
|
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
|
||||||
|
|
||||||
from langchain_community.chat_models.moonshot import MoonshotChat
|
from langchain_community.chat_models.moonshot import MoonshotChat
|
||||||
|
|
||||||
|
|
||||||
def test_default_call() -> None:
|
class TestMoonshotChat(ChatModelIntegrationTests):
|
||||||
"""Test default model call."""
|
@property
|
||||||
chat = MoonshotChat() # type: ignore[call-arg]
|
def chat_model_class(self) -> Type[BaseChatModel]:
|
||||||
response = chat.invoke([HumanMessage(content="How are you?")])
|
return MoonshotChat
|
||||||
assert isinstance(response, BaseMessage)
|
|
||||||
assert isinstance(response.content, str)
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def chat_model_params(self) -> dict:
|
||||||
|
return {"model": "moonshot-v1-8k"}
|
||||||
|
|
||||||
def test_model() -> None:
|
@pytest.mark.xfail(reason="Not yet implemented.")
|
||||||
"""Test model kwarg works."""
|
def test_usage_metadata(self, model: BaseChatModel) -> None:
|
||||||
chat = MoonshotChat(model="moonshot-v1-32k") # type: ignore[call-arg]
|
super().test_usage_metadata(model)
|
||||||
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)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user