From bb377d4935153f2df98f6d73a76b698f120442b2 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 28 Jun 2023 17:27:28 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20set=20input=20k?= =?UTF-8?q?eys=20values=20from=20artifacts=20in=20build=5Finput=5Fkeys=5Fr?= =?UTF-8?q?esponse=20function=20=E2=9C=A8=20feat(utils.py):=20add=20suppor?= =?UTF-8?q?t=20for=20setting=20input=20keys=20values=20from=20artifacts=20?= =?UTF-8?q?in=20build=5Finput=5Fkeys=5Fresponse=20function=20The=20build?= =?UTF-8?q?=5Finput=5Fkeys=5Fresponse=20function=20now=20takes=20an=20addi?= =?UTF-8?q?tional=20parameter,=20artifacts,=20which=20is=20a=20dictionary?= =?UTF-8?q?=20containing=20key-value=20pairs.=20The=20function=20sets=20th?= =?UTF-8?q?e=20values=20of=20the=20input=20keys=20in=20the=20input=5Fkeys?= =?UTF-8?q?=5Fresponse=20dictionary=20based=20on=20the=20corresponding=20k?= =?UTF-8?q?eys=20in=20the=20artifacts=20dictionary.=20This=20allows=20for?= =?UTF-8?q?=20more=20flexibility=20in=20setting=20the=20input=20keys=20val?= =?UTF-8?q?ues=20dynamically=20based=20on=20the=20provided=20artifacts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/api/utils.py b/src/backend/langflow/api/utils.py index bd25d74f4..2df86eb7f 100644 --- a/src/backend/langflow/api/utils.py +++ b/src/backend/langflow/api/utils.py @@ -24,13 +24,18 @@ def remove_api_keys(flow: dict): return flow -def build_input_keys_response(langchain_object): +def build_input_keys_response(langchain_object, artifacts): """Build the input keys response.""" input_keys_response = { "input_keys": {key: "" for key in langchain_object.input_keys}, "memory_keys": [], } + + # Set the input keys values from artifacts + for key, value in artifacts.items(): + if key in input_keys_response["input_keys"]: + input_keys_response["input_keys"][key] = value # If the object has memory, that memory will have a memory_variables attribute # memory variables should be removed from the input keys if hasattr(langchain_object, "memory") and hasattr(