TestChatDeepSeekCustomUnit Class — langchain Architecture
Architecture documentation for the TestChatDeepSeekCustomUnit class in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 530201c5_d88b_5d70_4ba9_c13da0c872e6["TestChatDeepSeekCustomUnit"] 0998183a_ee20_cc02_d37b_948998ae74b7["AIMessageChunk"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|extends| 0998183a_ee20_cc02_d37b_948998ae74b7 5ea44688_e61e_5f0e_f4f7_57f0ea8b7bb6["test_chat_models.py"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|defined in| 5ea44688_e61e_5f0e_f4f7_57f0ea8b7bb6 2624b386_44c3_cc6d_22d4_03140f4f3693["test_create_chat_result_with_reasoning_content()"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|method| 2624b386_44c3_cc6d_22d4_03140f4f3693 38125966_3c35_be8e_95aa_e13bf1fbd650["test_create_chat_result_with_model_extra_reasoning()"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|method| 38125966_3c35_be8e_95aa_e13bf1fbd650 9b05c727_bac8_25e2_9243_d0aefd817a13["test_convert_chunk_with_reasoning_content()"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|method| 9b05c727_bac8_25e2_9243_d0aefd817a13 5485b390_870b_f8b1_0fa2_58ec26a0dd43["test_convert_chunk_with_reasoning()"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|method| 5485b390_870b_f8b1_0fa2_58ec26a0dd43 2f82b024_731c_8898_5992_9c986d30e47d["test_convert_chunk_without_reasoning()"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|method| 2f82b024_731c_8898_5992_9c986d30e47d 67d30ce5_804a_b23e_2488_7800b61ef9e3["test_convert_chunk_with_empty_delta()"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|method| 67d30ce5_804a_b23e_2488_7800b61ef9e3 8d3fb809_8513_3c1c_8ee4_c09a1b1c66f6["test_get_request_payload()"] 530201c5_d88b_5d70_4ba9_c13da0c872e6 -->|method| 8d3fb809_8513_3c1c_8ee4_c09a1b1c66f6
Relationship Graph
Source Code
libs/partners/deepseek/tests/unit_tests/test_chat_models.py lines 104–245
class TestChatDeepSeekCustomUnit:
"""Custom tests specific to DeepSeek chat model."""
def test_create_chat_result_with_reasoning_content(self) -> None:
"""Test that reasoning_content is properly extracted from response."""
chat_model = ChatDeepSeek(model=MODEL_NAME, api_key=SecretStr("api_key"))
mock_message = MagicMock()
mock_message.content = "Main content"
mock_message.reasoning_content = "This is the reasoning content"
mock_message.role = "assistant"
mock_response = MockOpenAIResponse(
choices=[MagicMock(message=mock_message)],
error=None,
)
result = chat_model._create_chat_result(mock_response)
assert (
result.generations[0].message.additional_kwargs.get("reasoning_content")
== "This is the reasoning content"
)
def test_create_chat_result_with_model_extra_reasoning(self) -> None:
"""Test that reasoning is properly extracted from `model_extra`."""
chat_model = ChatDeepSeek(model=MODEL_NAME, api_key=SecretStr("api_key"))
mock_message = MagicMock(spec=ChatCompletionMessage)
mock_message.content = "Main content"
mock_message.role = "assistant"
mock_message.model_extra = {"reasoning": "This is the reasoning"}
mock_message.model_dump.return_value = {
"role": "assistant",
"content": "Main content",
"model_extra": {"reasoning": "This is the reasoning"},
}
mock_choice = MagicMock()
mock_choice.message = mock_message
mock_response = MockOpenAIResponse(choices=[mock_choice], error=None)
result = chat_model._create_chat_result(mock_response)
assert (
result.generations[0].message.additional_kwargs.get("reasoning_content")
== "This is the reasoning"
)
def test_convert_chunk_with_reasoning_content(self) -> None:
"""Test that reasoning_content is properly extracted from streaming chunk."""
chat_model = ChatDeepSeek(model=MODEL_NAME, api_key=SecretStr("api_key"))
chunk: dict[str, Any] = {
"choices": [
{
"delta": {
"content": "Main content",
"reasoning_content": "Streaming reasoning content",
},
},
],
}
chunk_result = chat_model._convert_chunk_to_generation_chunk(
chunk,
AIMessageChunk,
None,
)
if chunk_result is None:
msg = "Expected chunk_result not to be None"
raise AssertionError(msg)
assert (
chunk_result.message.additional_kwargs.get("reasoning_content")
== "Streaming reasoning content"
)
def test_convert_chunk_with_reasoning(self) -> None:
"""Test that reasoning is properly extracted from streaming chunk."""
chat_model = ChatDeepSeek(model=MODEL_NAME, api_key=SecretStr("api_key"))
chunk: dict[str, Any] = {
"choices": [
{
"delta": {
"content": "Main content",
"reasoning": "Streaming reasoning",
},
},
Extends
Source
Frequently Asked Questions
What is the TestChatDeepSeekCustomUnit class?
TestChatDeepSeekCustomUnit is a class in the langchain codebase, defined in libs/partners/deepseek/tests/unit_tests/test_chat_models.py.
Where is TestChatDeepSeekCustomUnit defined?
TestChatDeepSeekCustomUnit is defined in libs/partners/deepseek/tests/unit_tests/test_chat_models.py at line 104.
What does TestChatDeepSeekCustomUnit extend?
TestChatDeepSeekCustomUnit extends AIMessageChunk.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free