Home / Function/ test_astream_with_model_override() — langchain Function Reference

test_astream_with_model_override() — langchain Function Reference

Architecture documentation for the test_astream_with_model_override() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b60a19af_8e2c_2b52_ed3a_d74be72c8736["test_astream_with_model_override()"]
  971e928f_9c9b_ce7a_b93d_e762f2f5aa54["ChatModelIntegrationTests"]
  b60a19af_8e2c_2b52_ed3a_d74be72c8736 -->|defined in| 971e928f_9c9b_ce7a_b93d_e762f2f5aa54
  style b60a19af_8e2c_2b52_ed3a_d74be72c8736 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/integration_tests/chat_models.py lines 1009–1037

    async def test_astream_with_model_override(self, model: BaseChatModel) -> None:
        """Test that model name can be overridden at astream 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
        async for chunk in model.astream("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

Frequently Asked Questions

What does test_astream_with_model_override() do?
test_astream_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_astream_with_model_override() defined?
test_astream_with_model_override() is defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py at line 1009.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free