diff --git a/libs/langchain/langchain/chains/base.py b/libs/langchain/langchain/chains/base.py index c4dd6989962..ce94a248b34 100644 --- a/libs/langchain/langchain/chains/base.py +++ b/libs/langchain/langchain/chains/base.py @@ -750,11 +750,11 @@ class Chain(RunnableSerializable[dict[str, Any], dict[str, Any]], ABC): Example: .. code-block:: python - chain.dict(exclude_unset=True) + chain.model_dump(exclude_unset=True) # -> {"_type": "foo", "verbose": False, ...} """ - _dict = super().dict(**kwargs) + _dict = super().model_dump(**kwargs) with contextlib.suppress(NotImplementedError): _dict["_type"] = self._chain_type return _dict @@ -779,7 +779,7 @@ class Chain(RunnableSerializable[dict[str, Any], dict[str, Any]], ABC): raise ValueError(msg) # Fetch dictionary to save - chain_dict = self.dict() + chain_dict = self.model_dump() if "_type" not in chain_dict: msg = f"Chain {self} does not support saving." raise NotImplementedError(msg) diff --git a/libs/partners/openai/tests/unit_tests/chat_models/test_azure.py b/libs/partners/openai/tests/unit_tests/chat_models/test_azure.py index a42cc69008e..05e60f85c7b 100644 --- a/libs/partners/openai/tests/unit_tests/chat_models/test_azure.py +++ b/libs/partners/openai/tests/unit_tests/chat_models/test_azure.py @@ -40,8 +40,8 @@ def test_initialize_more() -> None: assert llm.temperature == 0 ls_params = llm._get_ls_params() - assert ls_params["ls_provider"] == "azure" - assert ls_params["ls_model_name"] == "gpt-35-turbo-0125" + assert ls_params.get("ls_provider") == "azure" + assert ls_params.get("ls_model_name") == "gpt-35-turbo-0125" def test_initialize_azure_openai_with_openai_api_base_set() -> None: diff --git a/libs/partners/xai/tests/unit_tests/test_chat_models.py b/libs/partners/xai/tests/unit_tests/test_chat_models.py index b5af091004a..9763601917d 100644 --- a/libs/partners/xai/tests/unit_tests/test_chat_models.py +++ b/libs/partners/xai/tests/unit_tests/test_chat_models.py @@ -34,7 +34,7 @@ def test_xai_model_param() -> None: llm = ChatXAI(model_name="foo") # type: ignore[call-arg] assert llm.model_name == "foo" ls_params = llm._get_ls_params() - assert ls_params["ls_provider"] == "xai" + assert ls_params.get("ls_provider") == "xai" def test_chat_xai_invalid_streaming_params() -> None: