standard-tests: model param test

This commit is contained in:
Erick Friis 2025-02-04 18:01:24 -08:00
parent 621bba7e26
commit 6d58ccb013

View File

@ -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