🐛 fix(loading.py): add missing condition to check if variable is an instance of BaseOutputParser and has "get_format_instructions" attribute

The code was missing a condition to check if the variable is an instance of BaseOutputParser and has the "get_format_instructions" attribute. This condition is necessary to properly handle the variable and avoid potential errors.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-30 11:17:32 -03:00
commit 270d5fb106

View file

@ -149,6 +149,14 @@ def instantiate_prompt(node_type, class_object, params):
)
# handle_keys will be a list but it does not exist yet
# so we need to create it
if (
isinstance(variable, List)
and all(isinstance(item, Document) for item in variable)
) or (
isinstance(variable, BaseOutputParser)
and hasattr(variable, "get_format_instructions")
):
if "handle_keys" not in params:
format_kwargs["handle_keys"] = []