🐛 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:
parent
c9bb88933b
commit
6afca21e5a
1 changed files with 4 additions and 4 deletions
|
|
@ -37,11 +37,11 @@ def build_input_keys_response(langchain_object):
|
||||||
langchain_object.memory, "memory_variables"
|
langchain_object.memory, "memory_variables"
|
||||||
):
|
):
|
||||||
# Remove memory variables from input keys
|
# Remove memory variables from input keys
|
||||||
input_keys_response["input_keys"] = [
|
input_keys_response["input_keys"] = {
|
||||||
key
|
key: value
|
||||||
for key in input_keys_response["input_keys"]
|
for key, value in input_keys_response["input_keys"].items()
|
||||||
if key not in langchain_object.memory.memory_variables
|
if key not in langchain_object.memory.memory_variables
|
||||||
]
|
}
|
||||||
# Add memory variables to memory_keys
|
# Add memory variables to memory_keys
|
||||||
input_keys_response["memory_keys"] = langchain_object.memory.memory_variables
|
input_keys_response["memory_keys"] = langchain_object.memory.memory_variables
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue