🐛 fix(loading.py): remove empty input_key and output_key from params dictionary

The code now removes the "input_key" and "output_key" keys from the params dictionary if they are empty strings. This ensures that the dictionary does not contain unnecessary keys with empty values.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-06 15:32:18 -03:00
commit ac9969624e

View file

@ -111,6 +111,12 @@ def instantiate_llm(node_type, class_object, params: Dict):
def instantiate_memory(node_type, class_object, params):
# process input_key and output_key to remove them if
# they are empty strings
for key in ["input_key", "output_key"]:
if key in params and not params[key]:
params.pop(key)
try:
if "retriever" in params and hasattr(params["retriever"], "as_retriever"):
params["retriever"] = params["retriever"].as_retriever()