Home / Function/ test_ainvoke_with_model_override() — langchain Function Reference

test_ainvoke_with_model_override() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/integration_tests/chat_models.py lines 952–977

    async def test_ainvoke_with_model_override(self, model: BaseChatModel) -> None:
        """Test that model name can be overridden at ainvoke 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.")

        result = await model.ainvoke("Hello", model=override_model)
        assert result is not None
        assert isinstance(result, AIMessage)

        # Verify the overridden model was used
        model_name = result.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_ainvoke_with_model_override() do?
test_ainvoke_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_ainvoke_with_model_override() defined?
test_ainvoke_with_model_override() is defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py at line 952.

Analyze Your Own Codebase

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

Try Supermodel Free