描述bug
在使用 output_type
参数中的 List
时,YAML反序列化失败。以下是一个示例:
from haystack import Pipeline
pipeline_yaml = """
components:
output_adapter:
type: haystack.components.converters.output_adapter.OutputAdapter
init_parameters:
output_type: "List[str]"
template: "{{ test }}"
"""
Pipeline.loads(pipeline_yaml)
错误信息
Traceback (most recent call last):
File "../haystack/haystack/core/pipeline/base.py", line 186, in from_dict
instance = component_from_dict(component_class, component_data, name, callbacks)
File "../haystack/haystack/core/serialization.py", line 118, in component_from_dict
return do_from_dict()
File "../haystack/haystack/core/serialization.py", line 113, in do_from_dict
return cls.from_dict(data)
File "../haystack/haystack/components/converters/output_adapter.py", line 141, in from_dict
init_params["output_type"] = deserialize_type(init_params["output_type"])
File "../haystack/haystack/utils/type_serialization.py", line 117, in deserialize_type
main_type = deserialize_type(main_type_str)
File "/Users/tanaysoni/haystack/haystack/utils/type_serialization.py", line 142, in deserialize_type
raise DeserializationError(f"Could not locate the type: {type_name} in the module: {module_name}")
haystack.core.errors.DeserializationError: Could not locate the type: List in the module: builtins
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "../haystack/script.py", line 22, in <module>
Pipeline.loads(pipeline_yaml)
File "../haystack/haystack/core/pipeline/base.py", line 258, in loads
return cls.from_dict(deserialized_data, callbacks)
File "../haystack/haystack/core/pipeline/base.py", line 195, in from_dict
raise DeserializationError(msg) from e
haystack.core.errors.DeserializationError: Couldn't deserialize component 'output_adapter' of class 'OutputAdapter' with the following data: {'type': 'haystack.components.converters.output_adapter.OutputAdapter', 'init_parameters': {'output_type': 'List[str]', 'template': '{{ test }}'}}. Possible reasons include malformed serialized data, mismatch between the serialized component and the loaded one (due to a breaking change, see https://github.com/deepset-ai/haystack/releases), etc.
预期行为
对您期望发生的事情进行清晰简洁的描述。
附加上下文
在此添加有关问题的其他上下文,例如文档类型/预处理步骤/阅读器设置等。
重现
重现行为所需的步骤
FAQ检查
- 您是否查看了 our new FAQ page ?
系统: - OS:
- GPU/CPU:
- Haystack版本(提交或版本号):
- 文档存储:
- 阅读器:
- 检索器:
1条答案
按热度按时间g6ll5ycj1#
@oryx1729 would you please try using typing.List[str] i.e. the full class name. That should work, see #8196 for more details. Let us know 🙏