From 5445adbbce1b3693e0b5e21b24f70b1a4e5a57b8 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 4 Jul 2023 23:32:25 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(validate.py):=20set=20new=20?= =?UTF-8?q?field=20value=20with=20the=20old=20value=20if=20variable=20alre?= =?UTF-8?q?ady=20exists=20in=20the=20template=20The=20code=20now=20checks?= =?UTF-8?q?=20if=20the=20variable=20already=20exists=20in=20the=20template?= =?UTF-8?q?=20and=20if=20so,=20sets=20the=20new=20field=20value=20with=20t?= =?UTF-8?q?he=20old=20value.=20This=20ensures=20that=20the=20existing=20va?= =?UTF-8?q?lue=20is=20preserved=20when=20adding=20new=20variables=20to=20t?= =?UTF-8?q?he=20template.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/validate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/api/v1/validate.py b/src/backend/langflow/api/v1/validate.py index 362430cf8..aa3748785 100644 --- a/src/backend/langflow/api/v1/validate.py +++ b/src/backend/langflow/api/v1/validate.py @@ -74,7 +74,11 @@ def add_new_variables_to_template(input_variables, prompt_request): multiline=True, input_types=["Document", "BaseOutputParser"], ) - + if variable in prompt_request.frontend_node.template: + # Set the new field with the old value + template_field.value = prompt_request.frontend_node.template[variable][ + "value" + ] prompt_request.frontend_node.template[variable] = template_field.to_dict() # Check if variable is not already in the list before appending