From 7cbad3695616d397cd5e6e184337b620d918d2e3 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Thu, 5 Sep 2024 17:01:03 -0700 Subject: [PATCH] Add back Pregel.copy() --- libs/langgraph/langgraph/pregel/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/__init__.py b/libs/langgraph/langgraph/pregel/__init__.py index 2a132381b..2537ca0e4 100644 --- a/libs/langgraph/langgraph/pregel/__init__.py +++ b/libs/langgraph/langgraph/pregel/__init__.py @@ -253,10 +253,12 @@ class Pregel(Runnable[Union[dict[str, Any], Any], Union[dict[str, Any], Any]]): if auto_validate: self.validate() + def copy(self, update: dict[str, Any]) -> Self: + attrs = {**self.__dict__, **update} + return Pregel(**attrs) + def with_config(self, config: RunnableConfig | None = None, **kwargs: Any) -> Self: - attrs = {**self.__dict__} - attrs["config"] = merge_configs(self.config, config, kwargs) - return self.__class__(**attrs) + return self.copy({"config": merge_configs(self.config, config, kwargs)}) def validate(self) -> Self: validate_graph(