🐛 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:
parent
fe16467914
commit
270d5fb106
1 changed files with 8 additions and 0 deletions
|
|
@ -149,6 +149,14 @@ def instantiate_prompt(node_type, class_object, params):
|
||||||
)
|
)
|
||||||
# handle_keys will be a list but it does not exist yet
|
# handle_keys will be a list but it does not exist yet
|
||||||
# so we need to create it
|
# 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:
|
if "handle_keys" not in params:
|
||||||
format_kwargs["handle_keys"] = []
|
format_kwargs["handle_keys"] = []
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue