From cc6cf4df35283d6007b3a88e6d9c9707ef785149 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 18 Sep 2023 09:34:30 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(validate.py):=20set=20prompt?= =?UTF-8?q?=5Frequest.name=20to=20the=20key=20of=20the=20only=20custom=20f?= =?UTF-8?q?ield=20if=20it=20is=20an=20empty=20string=20and=20there=20is=20?= =?UTF-8?q?only=20one=20custom=20field=20to=20handle=20the=20first=20promp?= =?UTF-8?q?t=20request=20after=20node=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/validate.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/langflow/api/v1/validate.py b/src/backend/langflow/api/v1/validate.py index 2a5bdd673..e1c514aaa 100644 --- a/src/backend/langflow/api/v1/validate.py +++ b/src/backend/langflow/api/v1/validate.py @@ -53,6 +53,16 @@ def post_validate_prompt(prompt_request: ValidatePromptRequest): def get_old_custom_fields(prompt_request): try: + if ( + len(prompt_request.frontend_node.custom_fields) == 1 + and prompt_request.name == "" + ): + # If there is only one custom field and the name is empty string + # then we are dealing with the first prompt request after the node was created + prompt_request.name = list( + prompt_request.frontend_node.custom_fields.keys() + )[0] + old_custom_fields = prompt_request.frontend_node.custom_fields[ prompt_request.name ].copy()