From 270d5fb1066fc643bea6d8808352eca89c47c0cb Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 30 Jun 2023 11:17:32 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20add=20mis?= =?UTF-8?q?sing=20condition=20to=20check=20if=20variable=20is=20an=20insta?= =?UTF-8?q?nce=20of=20BaseOutputParser=20and=20has=20"get=5Fformat=5Finstr?= =?UTF-8?q?uctions"=20attribute=20The=20code=20was=20missing=20a=20conditi?= =?UTF-8?q?on=20to=20check=20if=20the=20variable=20is=20an=20instance=20of?= =?UTF-8?q?=20BaseOutputParser=20and=20has=20the=20"get=5Fformat=5Finstruc?= =?UTF-8?q?tions"=20attribute.=20This=20condition=20is=20necessary=20to=20?= =?UTF-8?q?properly=20handle=20the=20variable=20and=20avoid=20potential=20?= =?UTF-8?q?errors.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/initialize/loading.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index 6267dd400..bc8c7f0cf 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -149,6 +149,14 @@ def instantiate_prompt(node_type, class_object, params): ) # handle_keys will be a list but it does not exist yet # so we need to create it + + if ( + isinstance(variable, List) + and all(isinstance(item, Document) for item in variable) + ) or ( + isinstance(variable, BaseOutputParser) + and hasattr(variable, "get_format_instructions") + ): if "handle_keys" not in params: format_kwargs["handle_keys"] = [] From 0eead8f3f74ab700d27b65281af2a9ef91b9b1ef Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 30 Jun 2023 11:23:19 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20fix=20con?= =?UTF-8?q?dition=20to=20check=20for=20"handle=5Fkeys"=20in=20format=5Fkwa?= =?UTF-8?q?rgs=20instead=20of=20params=20The=20condition=20to=20check=20fo?= =?UTF-8?q?r=20the=20presence=20of=20"handle=5Fkeys"=20has=20been=20fixed?= =?UTF-8?q?=20to=20correctly=20check=20for=20its=20existence=20in=20the=20?= =?UTF-8?q?format=5Fkwargs=20dictionary=20instead=20of=20the=20params=20di?= =?UTF-8?q?ctionary.=20This=20ensures=20that=20the=20"handle=5Fkeys"=20lis?= =?UTF-8?q?t=20is=20properly=20populated=20when=20necessary.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/initialize/loading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index bc8c7f0cf..e8d9cade4 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -157,7 +157,7 @@ def instantiate_prompt(node_type, class_object, params): isinstance(variable, BaseOutputParser) and hasattr(variable, "get_format_instructions") ): - if "handle_keys" not in params: + if "handle_keys" not in format_kwargs: format_kwargs["handle_keys"] = [] # Add the handle_keys to the list