test_chat_models.py — langchain Source File
Architecture documentation for test_chat_models.py, a python file in the langchain codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d4257bcf_53b5_3d9d_8446_0324e133716e["test_chat_models.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] d4257bcf_53b5_3d9d_8446_0324e133716e --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 525a7d6f_f455_56e3_854a_c8a7da4a1417["unittest.mock"] d4257bcf_53b5_3d9d_8446_0324e133716e --> 525a7d6f_f455_56e3_854a_c8a7da4a1417 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] d4257bcf_53b5_3d9d_8446_0324e133716e --> d758344f_537f_649e_f467_b9d7442e86df bab3058f_1ec6_5a8a_2b11_86f46e62adb4["langchain_tests.unit_tests"] d4257bcf_53b5_3d9d_8446_0324e133716e --> bab3058f_1ec6_5a8a_2b11_86f46e62adb4 45fc8fd3_e815_b442_a6d1_0dedc9327b62["openai"] d4257bcf_53b5_3d9d_8446_0324e133716e --> 45fc8fd3_e815_b442_a6d1_0dedc9327b62 2bceeb01_9fd5_3638_14d6_78a5df35c5bd["openai.types.chat"] d4257bcf_53b5_3d9d_8446_0324e133716e --> 2bceeb01_9fd5_3638_14d6_78a5df35c5bd 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] d4257bcf_53b5_3d9d_8446_0324e133716e --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 659def14_b4e3_f621_1458_ea1a98a4b31c["langchain_deepseek.chat_models"] d4257bcf_53b5_3d9d_8446_0324e133716e --> 659def14_b4e3_f621_1458_ea1a98a4b31c style d4257bcf_53b5_3d9d_8446_0324e133716e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Test chat model integration."""
from __future__ import annotations
from typing import Any, Literal
from unittest.mock import MagicMock
from langchain_core.messages import AIMessageChunk, ToolMessage
from langchain_tests.unit_tests import ChatModelUnitTests
from openai import BaseModel
from openai.types.chat import ChatCompletionMessage
from pydantic import BaseModel as PydanticBaseModel
from pydantic import Field, SecretStr
from langchain_deepseek.chat_models import DEFAULT_API_BASE, ChatDeepSeek
MODEL_NAME = "deepseek-chat"
class MockOpenAIResponse(BaseModel):
"""Mock OpenAI response model."""
choices: list
error: None = None
def model_dump( # type: ignore[override]
self,
*,
mode: Literal["json", "python"] | str = "python", # noqa: PYI051
include: Any = None,
exclude: Any = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: Literal["none", "warn", "error"] | bool = True,
context: dict[str, Any] | None = None,
serialize_as_any: bool = False,
) -> dict[str, Any]:
"""Convert to dictionary, ensuring `reasoning_content` is included."""
choices_list = []
for choice in self.choices:
if isinstance(choice.message, ChatCompletionMessage):
message_dict = choice.message.model_dump()
# Ensure model_extra fields are at top level
if "model_extra" in message_dict:
message_dict.update(message_dict["model_extra"])
else:
message_dict = {
"role": "assistant",
"content": choice.message.content,
}
# Add reasoning_content if present
if hasattr(choice.message, "reasoning_content"):
message_dict["reasoning_content"] = choice.message.reasoning_content
# Add model_extra fields at the top level if present
if hasattr(choice.message, "model_extra"):
message_dict.update(choice.message.model_extra)
message_dict["model_extra"] = choice.message.model_extra
// ... (257 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- langchain_core.messages
- langchain_deepseek.chat_models
- langchain_tests.unit_tests
- openai
- openai.types.chat
- pydantic
- typing
- unittest.mock
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 1 function(s): test_profile.
What does test_chat_models.py depend on?
test_chat_models.py imports 8 module(s): langchain_core.messages, langchain_deepseek.chat_models, langchain_tests.unit_tests, openai, openai.types.chat, pydantic, typing, unittest.mock.
Where is test_chat_models.py in the architecture?
test_chat_models.py is located at libs/partners/deepseek/tests/unit_tests/test_chat_models.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/deepseek/tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free