Skip to content

Commit

Permalink
multiple: standard chat model tests (langchain-ai#20359)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis committed Apr 12, 2024
1 parent f78564d commit e6806a0
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 11 deletions.
22 changes: 19 additions & 3 deletions libs/partners/ai21/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libs/partners/ai21/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ syrupy = "^4.0.2"
pytest-watcher = "^0.3.4"
pytest-asyncio = "^0.21.1"
langchain-core = { path = "../../core", develop = true }
langchain-standard-tests = {path = "../../standard-tests", develop = true}

[tool.poetry.group.codespell]
optional = true
Expand Down
21 changes: 21 additions & 0 deletions libs/partners/ai21/tests/integration_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests

from langchain_ai21 import ChatAI21


class TestAI21Standard(ChatModelIntegrationTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatAI21

@pytest.fixture
def chat_model_params(self) -> dict:
return {
"model": "j2-ultra",
}
22 changes: 22 additions & 0 deletions libs/partners/ai21/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests

from langchain_ai21 import ChatAI21


class TestAI21Standard(ChatModelUnitTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatAI21

@pytest.fixture
def chat_model_params(self) -> dict:
return {
"model": "j2-ultra",
"api_key": "test_api_key",
}
21 changes: 19 additions & 2 deletions libs/partners/anthropic/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libs/partners/anthropic/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pytest-watcher = "^0.3.4"
pytest-asyncio = "^0.21.1"
langchain-core = { path = "../../core", develop = true }
defusedxml = "^0.7.1"
langchain-standard-tests = {path = "../../standard-tests", develop = true}

[tool.poetry.group.codespell]
optional = true
Expand Down
21 changes: 21 additions & 0 deletions libs/partners/anthropic/tests/integration_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests

from langchain_anthropic import ChatAnthropic


class TestAnthropicStandard(ChatModelIntegrationTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatAnthropic

@pytest.fixture
def chat_model_params(self) -> dict:
return {
"model": "claude-3-haiku-20240307",
}
21 changes: 21 additions & 0 deletions libs/partners/anthropic/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests

from langchain_anthropic import ChatAnthropic


class TestAnthropicStandard(ChatModelUnitTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatAnthropic

@pytest.fixture
def chat_model_params(self) -> dict:
return {
"model": "claude-3-haiku-20240307",
}
21 changes: 19 additions & 2 deletions libs/partners/fireworks/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libs/partners/fireworks/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ syrupy = "^4.0.2"
pytest-watcher = "^0.3.4"
pytest-asyncio = "^0.21.1"
langchain-core = { path = "../../core", develop = true }
langchain-standard-tests = {path = "../../standard-tests", develop = true}

[tool.poetry.group.codespell]
optional = true
Expand Down
15 changes: 15 additions & 0 deletions libs/partners/fireworks/tests/integration_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests

from langchain_fireworks import ChatFireworks


class TestFireworksStandard(ChatModelIntegrationTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatFireworks
21 changes: 21 additions & 0 deletions libs/partners/fireworks/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests

from langchain_fireworks import ChatFireworks


class TestFireworksStandard(ChatModelUnitTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatFireworks

@pytest.fixture
def chat_model_params(self) -> dict:
return {
"api_key": "test_api_key",
}
21 changes: 19 additions & 2 deletions libs/partners/groq/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libs/partners/groq/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pytest-mock = "^3.10.0"
pytest-watcher = "^0.3.4"
pytest-asyncio = "^0.21.1"
langchain-core = { path = "../../core", develop = true }
langchain-standard-tests = {path = "../../standard-tests", develop = true}

[tool.poetry.group.codespell]
optional = true
Expand Down
15 changes: 15 additions & 0 deletions libs/partners/groq/tests/integration_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests

from langchain_groq import ChatGroq


class TestMistralStandard(ChatModelIntegrationTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatGroq
15 changes: 15 additions & 0 deletions libs/partners/groq/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Standard LangChain interface tests"""

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests

from langchain_groq import ChatGroq


class TestGroqStandard(ChatModelUnitTests):
@pytest.fixture
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatGroq
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def chat_model_has_tool_calling(
def chat_model_has_structured_output(
self, chat_model_class: Type[BaseChatModel]
) -> bool:
return hasattr(chat_model_class, "with_structured_output")
return (
chat_model_class.with_structured_output
is not BaseChatModel.with_structured_output
)

def test_chat_model_init(
self, chat_model_class: Type[BaseChatModel], chat_model_params: dict
Expand All @@ -49,7 +52,8 @@ def test_chat_model_init(
def test_chat_model_init_api_key(
self, chat_model_class: Type[BaseChatModel], chat_model_params: dict
) -> None:
model = chat_model_class(api_key="test", **chat_model_params) # type: ignore
params = {**chat_model_params, "api_key": "test"}
model = chat_model_class(**params) # type: ignore
assert model is not None

def test_chat_model_init_streaming(
Expand Down

0 comments on commit e6806a0

Please sign in to comment.