test_stream_with_model_override() — langchain Function Reference
Architecture documentation for the test_stream_with_model_override() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5fa2eef7_d009_965a_f504_5c82c0f04b34["test_stream_with_model_override()"] 971e928f_9c9b_ce7a_b93d_e762f2f5aa54["ChatModelIntegrationTests"] 5fa2eef7_d009_965a_f504_5c82c0f04b34 -->|defined in| 971e928f_9c9b_ce7a_b93d_e762f2f5aa54 style 5fa2eef7_d009_965a_f504_5c82c0f04b34 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/chat_models.py lines 979–1007
def test_stream_with_model_override(self, model: BaseChatModel) -> None:
"""Test that model name can be overridden at stream time via kwargs.
Test is skipped if `supports_model_override` is `False`.
??? question "Troubleshooting"
See troubleshooting for `test_invoke_with_model_override`.
"""
if not self.supports_model_override:
pytest.skip("Model override not supported.")
override_model = self.model_override_value
if not override_model:
pytest.skip("model_override_value not specified.")
full: AIMessageChunk | None = None
for chunk in model.stream("Hello", model=override_model):
assert isinstance(chunk, AIMessageChunk)
full = chunk if full is None else full + chunk
assert full is not None
# Verify the overridden model was used
model_name = full.response_metadata.get("model_name")
assert model_name is not None, "model_name not found in response_metadata"
assert override_model in model_name, (
f"Expected model '{override_model}' but got '{model_name}'"
)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_stream_with_model_override() do?
test_stream_with_model_override() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py.
Where is test_stream_with_model_override() defined?
test_stream_with_model_override() is defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py at line 979.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free