From 0b6a650cb4e24e7a9cee2090c618ff246a82fbcd Mon Sep 17 00:00:00 2001 From: Francisco Ingham Date: Tue, 21 Feb 2023 02:00:32 -0300 Subject: [PATCH] =?UTF-8?q?added=20ability=20to=20override=20default=20ver?= =?UTF-8?q?bose=20and=20memory=20when=20load=20chain=20=E2=80=A6=20(#1153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is useful to be able to specify `verbose` or `memory` while still keeping the chain's overall structure. --------- Co-authored-by: Francisco Ingham <> --- langchain/chains/loading.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/langchain/chains/loading.py b/langchain/chains/loading.py index 765ecf8f..026f47bc 100644 --- a/langchain/chains/loading.py +++ b/langchain/chains/loading.py @@ -463,5 +463,12 @@ def _load_chain_from_file(file: Union[str, Path], **kwargs: Any) -> Chain: config = yaml.safe_load(f) else: raise ValueError("File type must be json or yaml") + + # Override default 'verbose' and 'memory' for the chain + if "verbose" in kwargs: + config["verbose"] = kwargs.pop("verbose") + if "memory" in kwargs: + config["memory"] = kwargs.pop("memory") + # Load the chain from the config now. return load_chain_from_config(config, **kwargs)