test_chat_models.py — langchain Source File
Architecture documentation for test_chat_models.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e0f1ea46_1f74_0cf1_b991_97d6f807c516["test_chat_models.py"] 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] e0f1ea46_1f74_0cf1_b991_97d6f807c516 --> 120e2591_3e15_b895_72b6_cb26195e40a6 ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] e0f1ea46_1f74_0cf1_b991_97d6f807c516 --> ba43b74d_3099_7e1c_aac3_cf594720469e d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] e0f1ea46_1f74_0cf1_b991_97d6f807c516 --> d758344f_537f_649e_f467_b9d7442e86df 43d88577_548b_2248_b01b_7987bae85dcc["langchain_core.tools"] e0f1ea46_1f74_0cf1_b991_97d6f807c516 --> 43d88577_548b_2248_b01b_7987bae85dcc 8f882798_3f47_fa1f_5253_3b7193f357a9["langchain_tests.integration_tests"] e0f1ea46_1f74_0cf1_b991_97d6f807c516 --> 8f882798_3f47_fa1f_5253_3b7193f357a9 659def14_b4e3_f621_1458_ea1a98a4b31c["langchain_deepseek.chat_models"] e0f1ea46_1f74_0cf1_b991_97d6f807c516 --> 659def14_b4e3_f621_1458_ea1a98a4b31c style e0f1ea46_1f74_0cf1_b991_97d6f807c516 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test ChatDeepSeek chat model."""
from __future__ import annotations
import pytest
from langchain_core.language_models import BaseChatModel
from langchain_core.messages import AIMessageChunk, BaseMessageChunk
from langchain_core.tools import BaseTool
from langchain_tests.integration_tests import ChatModelIntegrationTests
from langchain_deepseek.chat_models import ChatDeepSeek
MODEL_NAME = "deepseek-chat"
class TestChatDeepSeek(ChatModelIntegrationTests):
"""Test `ChatDeepSeek` chat model."""
@property
def chat_model_class(self) -> type[ChatDeepSeek]:
"""Return class of chat model being tested."""
return ChatDeepSeek
@property
def chat_model_params(self) -> dict:
"""Parameters to create chat model instance for testing."""
return {
"model": MODEL_NAME,
"temperature": 0,
}
@property
def supports_json_mode(self) -> bool:
"""(bool) whether the chat model supports JSON mode."""
return True
@pytest.mark.xfail(reason="Not yet supported.")
def test_tool_message_histories_list_content(
self,
model: BaseChatModel,
my_adder_tool: BaseTool,
) -> None:
"""Override test for tool message histories with list content."""
super().test_tool_message_histories_list_content(model, my_adder_tool)
@pytest.mark.xfail(reason="Takes > 30s to run.")
def test_reasoning_content() -> None:
"""Test reasoning content."""
chat_model = ChatDeepSeek(model="deepseek-reasoner")
response = chat_model.invoke("What is 3^3?")
assert response.content
assert response.additional_kwargs["reasoning_content"]
content_blocks = response.content_blocks
assert content_blocks is not None
assert len(content_blocks) > 0
reasoning_blocks = [
block for block in content_blocks if block.get("type") == "reasoning"
]
assert len(reasoning_blocks) > 0
raise ValueError
@pytest.mark.xfail(reason="Takes > 30s to run.")
def test_reasoning_content_streaming() -> None:
"""Test reasoning content with streaming."""
chat_model = ChatDeepSeek(model="deepseek-reasoner")
full: BaseMessageChunk | None = None
for chunk in chat_model.stream("What is 3^3?"):
full = chunk if full is None else full + chunk
assert isinstance(full, AIMessageChunk)
assert full.additional_kwargs["reasoning_content"]
content_blocks = full.content_blocks
assert content_blocks is not None
assert len(content_blocks) > 0
reasoning_blocks = [
block for block in content_blocks if block.get("type") == "reasoning"
]
assert len(reasoning_blocks) > 0
Domain
Subdomains
Classes
Dependencies
- langchain_core.language_models
- langchain_core.messages
- langchain_core.tools
- langchain_deepseek.chat_models
- langchain_tests.integration_tests
- pytest
Source
Frequently Asked Questions
What does test_chat_models.py do?
test_chat_models.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_chat_models.py?
test_chat_models.py defines 2 function(s): test_reasoning_content, test_reasoning_content_streaming.
What does test_chat_models.py depend on?
test_chat_models.py imports 6 module(s): langchain_core.language_models, langchain_core.messages, langchain_core.tools, langchain_deepseek.chat_models, langchain_tests.integration_tests, pytest.
Where is test_chat_models.py in the architecture?
test_chat_models.py is located at libs/partners/deepseek/tests/integration_tests/test_chat_models.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/deepseek/tests/integration_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free