Home / Function/ test_serdes() — langchain Function Reference

test_serdes() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  2346742a_4b2c_370f_f060_b14e66b348ce["test_serdes()"]
  f4b40f56_1158_0e72_1cac_d0121e4eabd8["ChatModelUnitTests"]
  2346742a_4b2c_370f_f060_b14e66b348ce -->|defined in| f4b40f56_1158_0e72_1cac_d0121e4eabd8
  style 2346742a_4b2c_370f_f060_b14e66b348ce fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/unit_tests/chat_models.py lines 1108–1134

    def test_serdes(self, model: BaseChatModel, snapshot: SnapshotAssertion) -> None:
        """Test serialization and deserialization of the model.

        Test is skipped if the `is_lc_serializable` property on the chat model class
        is not overwritten to return `True`.

        ??? question "Troubleshooting"

            If this test fails, check that the `init_from_env_params` property is
            correctly set on the test class.
        """
        if not self.chat_model_class.is_lc_serializable():
            pytest.skip("Model is not serializable.")
        else:
            env_params, _model_params, _expected_attrs = self.init_from_env_params
            with mock.patch.dict(os.environ, env_params):
                ser = dumpd(model)
                assert ser == snapshot(name="serialized")
                assert (
                    model.dict()
                    == load(
                        dumpd(model),
                        valid_namespaces=model.get_lc_namespace()[:1],
                        allowed_objects="all",
                        secrets_from_env=True,
                    ).dict()
                )

Domain

Subdomains

Frequently Asked Questions

What does test_serdes() do?
test_serdes() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/unit_tests/chat_models.py.
Where is test_serdes() defined?
test_serdes() is defined in libs/standard-tests/langchain_tests/unit_tests/chat_models.py at line 1108.

Analyze Your Own Codebase

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

Try Supermodel Free