ChatModelIntegrationTests Class — langchain Architecture
Architecture documentation for the ChatModelIntegrationTests class in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 82a73afa_4570_e4e0_ee0b_cee9788da0b5["ChatModelIntegrationTests"] 39468aac_d3b1_1e4e_47c8_632f3ee4dd57["ChatModelTests"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|extends| 39468aac_d3b1_1e4e_47c8_632f3ee4dd57 fcfa55b0_4a86_fa31_a156_3c38c76a0a9b["AIMessage"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|extends| fcfa55b0_4a86_fa31_a156_3c38c76a0a9b 17a9b92d_bb83_78d8_7df7_7200745cc17b["AIMessageChunk"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|extends| 17a9b92d_bb83_78d8_7df7_7200745cc17b 93890837_6ece_efd1_afc9_cd35cbe2a745["Joke"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|extends| 93890837_6ece_efd1_afc9_cd35cbe2a745 e8f4dc2e_6d49_5eaf_d081_9659a9cfbd03["JokeDict"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|extends| e8f4dc2e_6d49_5eaf_d081_9659a9cfbd03 4318b819_4fe9_65b0_5369_424ec9518efe["ToolMessage"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|extends| 4318b819_4fe9_65b0_5369_424ec9518efe 872af98b_38b0_5d04_99e4_7f348acb4cfb["chat_models.py"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|defined in| 872af98b_38b0_5d04_99e4_7f348acb4cfb 6228d25c_d2bb_bb71_758f_13089db6c126["standard_chat_model_params()"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|method| 6228d25c_d2bb_bb71_758f_13089db6c126 dd0fb403_cfc6_9a50_fc61_eb1225af3d85["test_invoke()"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|method| dd0fb403_cfc6_9a50_fc61_eb1225af3d85 2ff17efa_bba3_d149_ffad_089ee67ba3e6["test_ainvoke()"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|method| 2ff17efa_bba3_d149_ffad_089ee67ba3e6 2d75665a_b766_037c_6e84_8bbc457c3ddc["test_stream()"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|method| 2d75665a_b766_037c_6e84_8bbc457c3ddc c2866ab8_7e6a_9d20_6dc8_a40ae45a9ab0["test_astream()"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|method| c2866ab8_7e6a_9d20_6dc8_a40ae45a9ab0 46ba5a4f_d62a_6753_09a8_7e4289064a26["test_invoke_with_model_override()"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|method| 46ba5a4f_d62a_6753_09a8_7e4289064a26 5e48fb87_e86a_b446_4fdd_7b4aa7af213a["test_ainvoke_with_model_override()"] 82a73afa_4570_e4e0_ee0b_cee9788da0b5 -->|method| 5e48fb87_e86a_b446_4fdd_7b4aa7af213a
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/chat_models.py lines 173–3455
class ChatModelIntegrationTests(ChatModelTests):
'''Base class for chat model integration tests.
Test subclasses must implement the `chat_model_class` and
`chat_model_params` properties to specify what model to test and its
initialization parameters.
```python
from typing import Type
from langchain_tests.integration_tests import ChatModelIntegrationTests
from my_package.chat_models import MyChatModel
class TestMyChatModelIntegration(ChatModelIntegrationTests):
@property
def chat_model_class(self) -> Type[MyChatModel]:
# Return the chat model class to test here
return MyChatModel
@property
def chat_model_params(self) -> dict:
# Return initialization parameters for the model.
return {"model": "model-001", "temperature": 0}
```
!!! note
API references for individual test methods include troubleshooting tips.
Test subclasses **must** implement the following two properties:
`chat_model_class`: The chat model class to test, e.g., `ChatParrotLink`.
```python
@property
def chat_model_class(self) -> Type[ChatParrotLink]:
return ChatParrotLink
```
`chat_model_params`: Initialization parameters for the chat model.
```python
@property
def chat_model_params(self) -> dict:
return {"model": "bird-brain-001", "temperature": 0}
```
In addition, test subclasses can control what features are tested (such as tool
calling or multi-modality) by selectively overriding the following properties.
Expand to see details:
???+ info "`has_tool_calling`"
Boolean property indicating whether the chat model supports tool calling.
By default, this is determined by whether the chat model's `bind_tools` method
is overridden. It typically does not need to be overridden on the test class.
```python
@property
def has_tool_calling(self) -> bool:
return True
```
??? info "`has_tool_choice`"
Boolean property indicating whether the chat model supports forcing tool
calling via a `tool_choice` parameter.
By default, this is determined by whether the parameter is included in the
signature for the corresponding `bind_tools` method.
If `True`, the minimum requirement for this feature is that
`tool_choice='any'` will force a tool call, and `tool_choice=<tool name>`
will force a call to a specific tool.
```python
@property
def has_tool_choice(self) -> bool:
Source
Frequently Asked Questions
What is the ChatModelIntegrationTests class?
ChatModelIntegrationTests is a class in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py.
Where is ChatModelIntegrationTests defined?
ChatModelIntegrationTests is defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py at line 173.
What does ChatModelIntegrationTests extend?
ChatModelIntegrationTests extends ChatModelTests, AIMessage, AIMessageChunk, Joke, JokeDict, ToolMessage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free