🐛 fix(utils.py): fix build_input_keys_response function to correctly filter out memory variables from input keys

The build_input_keys_response function now correctly filters out memory variables from the input keys response. Previously, it was using a list comprehension to filter the keys, but it should have been using a dictionary comprehension to preserve the key-value pairs. This fix ensures that only the keys that are not present in the langchain_object's memory variables are included in the input keys response.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-28 17:13:06 -03:00
commit 6afca21e5a

View file

@ -37,11 +37,11 @@ def build_input_keys_response(langchain_object):
langchain_object.memory, "memory_variables"
):
# Remove memory variables from input keys
input_keys_response["input_keys"] = [
key
for key in input_keys_response["input_keys"]
input_keys_response["input_keys"] = {
key: value
for key, value in input_keys_response["input_keys"].items()
if key not in langchain_object.memory.memory_variables
]
}
# Add memory variables to memory_keys
input_keys_response["memory_keys"] = langchain_object.memory.memory_variables