test_base.py — langchain Source File
Architecture documentation for test_base.py, a python file in the langchain codebase. 9 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4f0dea20_a33a_454b_b3c3_bd28a1bb943f["test_base.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> 120e2591_3e15_b895_72b6_cb26195e40a6 ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> ba43b74d_3099_7e1c_aac3_cf594720469e d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> d758344f_537f_649e_f467_b9d7442e86df e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> e6b4f61e_7b98_6666_3641_26b069517d4a 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c 8f882798_3f47_fa1f_5253_3b7193f357a9["langchain_tests.integration_tests"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> 8f882798_3f47_fa1f_5253_3b7193f357a9 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 33308952_c339_c236_5265_e0ceb9865382["langchain_classic.chat_models"] 4f0dea20_a33a_454b_b3c3_bd28a1bb943f --> 33308952_c339_c236_5265_e0ceb9865382 style 4f0dea20_a33a_454b_b3c3_bd28a1bb943f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import cast
import pytest
from langchain_core.language_models import BaseChatModel
from langchain_core.messages import AIMessage
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableConfig
from langchain_tests.integration_tests import ChatModelIntegrationTests
from pydantic import BaseModel
from langchain_classic.chat_models import init_chat_model
class Multiply(BaseModel):
"""Product of two ints."""
x: int
y: int
@pytest.mark.requires("langchain_openai", "langchain_anthropic")
async def test_init_chat_model_chain() -> None:
model = init_chat_model("gpt-4o", configurable_fields="any", config_prefix="bar")
model_with_tools = model.bind_tools([Multiply])
model_with_config = model_with_tools.with_config(
RunnableConfig(tags=["foo"]),
configurable={"bar_model": "claude-sonnet-4-5-20250929"},
)
prompt = ChatPromptTemplate.from_messages([("system", "foo"), ("human", "{input}")])
chain = prompt | model_with_config
output = chain.invoke({"input": "bar"})
assert isinstance(output, AIMessage)
events = [
event async for event in chain.astream_events({"input": "bar"}, version="v2")
]
assert events
class TestStandard(ChatModelIntegrationTests):
@property
def chat_model_class(self) -> type[BaseChatModel]:
return cast("type[BaseChatModel]", init_chat_model)
@property
def chat_model_params(self) -> dict:
return {"model": "gpt-4o", "configurable_fields": "any"}
@property
def supports_image_inputs(self) -> bool:
return True
@property
def has_tool_calling(self) -> bool:
return True
@property
def has_structured_output(self) -> bool:
return True
Domain
Subdomains
Functions
Classes
Dependencies
- langchain_classic.chat_models
- langchain_core.language_models
- langchain_core.messages
- langchain_core.prompts
- langchain_core.runnables
- langchain_tests.integration_tests
- pydantic
- pytest
- typing
Source
Frequently Asked Questions
What does test_base.py do?
test_base.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_base.py?
test_base.py defines 1 function(s): test_init_chat_model_chain.
What does test_base.py depend on?
test_base.py imports 9 module(s): langchain_classic.chat_models, langchain_core.language_models, langchain_core.messages, langchain_core.prompts, langchain_core.runnables, langchain_tests.integration_tests, pydantic, pytest, and 1 more.
Where is test_base.py in the architecture?
test_base.py is located at libs/langchain/tests/integration_tests/chat_models/test_base.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/langchain/tests/integration_tests/chat_models).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free