diff --git a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py b/libs/standard-tests/langchain_tests/unit_tests/chat_models.py index e2b58d2f050..caba7f8d283 100644 --- a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py +++ b/libs/standard-tests/langchain_tests/unit_tests/chat_models.py @@ -85,6 +85,10 @@ class ChatModelTests(BaseStandardTests): """Initialization parameters for the chat model.""" return {} + @property + def chat_model_model_param(self) -> dict: + return self.chat_model_params.get("model", "test-model-name") + @property def standard_chat_model_params(self) -> dict: """:private:""" @@ -521,6 +525,29 @@ class ChatModelUnitTests(ChatModelTests): ) assert model is not None + def test_model_param_name(self) -> None: + """Tests model initializatiokn with a model= parameter. This should pass for all + integrations. + + .. dropdown:: Troubleshooting + + If this test fails, ensure that the model can be initialized with a + ``model`` parameter, and that the model parameter can be accessed as + ``.model``. + """ + params = { + **self.standard_chat_model_params, + **self.chat_model_params, + } + if "model_name" in params: + params["model"] = params.pop("model_name") + else: + params["model"] = self.chat_model_model_param + + model = self.chat_model_class(**params) + assert model is not None + assert model.model == params["model"] + def test_init_from_env(self) -> None: """Test initialization from environment variables. Relies on the ``init_from_env_params`` property. Test is skipped if that property is not