🐛 fix(utils.py): set input keys values from artifacts in build_input_keys_response function

 feat(utils.py): add support for setting input keys values from artifacts in build_input_keys_response function
The build_input_keys_response function now takes an additional parameter, artifacts, which is a dictionary containing key-value pairs. The function sets the values of the input keys in the input_keys_response dictionary based on the corresponding keys in the artifacts dictionary. This allows for more flexibility in setting the input keys values dynamically based on the provided artifacts.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-28 17:27:28 -03:00
commit bb377d4935

View file

@ -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(