mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-21 06:14:37 +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."""
|
||||
|
||||
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
|
||||
|
||||
|
||||
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)
|
||||
class TestMoonshotChat(ChatModelIntegrationTests):
|
||||
@property
|
||||
def chat_model_class(self) -> Type[BaseChatModel]:
|
||||
return MoonshotChat
|
||||
|
||||
@property
|
||||
def chat_model_params(self) -> dict:
|
||||
return {"model": "moonshot-v1-8k"}
|
||||
|
||||
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)
|
||||
@pytest.mark.xfail(reason="Not yet implemented.")
|
||||
def test_usage_metadata(self, model: BaseChatModel) -> None:
|
||||
super().test_usage_metadata(model)
|
||||
|
Loading…
Reference in New Issue
Block a user