From 2144e1ec91d88118d6553269a95ef8f8a0af63b7 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 14 Aug 2023 17:16:54 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(types.py):=20handle=20ca?= =?UTF-8?q?se=20where=20prompt=20template=20is=20not=20present=20in=20Prom?= =?UTF-8?q?ptVertex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ℹ️ The code was modified to handle a case where the `template` attribute is not present in the `PromptVertex` class. If the `template` attribute is not found, the code checks if the `prompt` attribute is present and uses its `template` attribute instead. This change ensures that the code does not break when the `template` attribute is missing. --- src/backend/langflow/graph/vertex/types.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/graph/vertex/types.py b/src/backend/langflow/graph/vertex/types.py index b7ac17983..9a2dc21c5 100644 --- a/src/backend/langflow/graph/vertex/types.py +++ b/src/backend/langflow/graph/vertex/types.py @@ -226,7 +226,12 @@ class PromptVertex(Vertex): # so the prompt format doesn't break artifacts.pop("handle_keys", None) try: - template = self._built_object.template + if not hasattr(self._built_object, "template") and hasattr( + self._built_object, "prompt" + ): + template = self._built_object.prompt.template + else: + template = self._built_object.template for key, value in artifacts.items(): if value: replace_key = "{" + key + "}" From e0f625e793dec099451ca698a5bd71557af72e2e Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 14 Aug 2023 17:17:57 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20add=20condi?= =?UTF-8?q?tion=20to=20check=20if=20prompt=20has=20'partial'=20attribute?= =?UTF-8?q?=20before=20calling=20it=20to=20prevent=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/initialize/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/initialize/utils.py b/src/backend/langflow/interface/initialize/utils.py index 976d8906c..ceb8a53a1 100644 --- a/src/backend/langflow/interface/initialize/utils.py +++ b/src/backend/langflow/interface/initialize/utils.py @@ -51,7 +51,9 @@ def handle_partial_variables(prompt, format_kwargs: Dict): } # Remove handle_keys otherwise LangChain raises an error partial_variables.pop("handle_keys", None) - return prompt.partial(**partial_variables) + if partial_variables and hasattr(prompt, "partial"): + return prompt.partial(**partial_variables) + return prompt def handle_variable(params: Dict, input_variable: str, format_kwargs: Dict):