mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-25 05:58:57 +00:00
fix: ChatPromptBuilder from_dict if template is None (#8165)
* fix ChatPromptBuilder from dict if template=None * fix ChatPromptBuilder from dict if template=None * leave template None --------- Co-authored-by: Marie-Luise Klaus <marieluise.klaus@deepset.ai>
This commit is contained in:
parent
2e2f5f17bb
commit
031b0bfbd8
@ -254,7 +254,8 @@ class ChatPromptBuilder:
|
||||
The deserialized component.
|
||||
"""
|
||||
init_parameters = data["init_parameters"]
|
||||
template = init_parameters.get("template", [])
|
||||
init_parameters["template"] = [ChatMessage.from_dict(d) for d in template]
|
||||
template = init_parameters.get("template")
|
||||
if template:
|
||||
init_parameters["template"] = [ChatMessage.from_dict(d) for d in template]
|
||||
|
||||
return default_from_dict(cls, data)
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix ChatPromptBuilder from_dict method when template value is None.
|
||||
@ -535,3 +535,15 @@ class TestChatPromptBuilderDynamic:
|
||||
]
|
||||
assert component._variables == ["var", "required_var"]
|
||||
assert component._required_variables == ["required_var"]
|
||||
|
||||
def test_from_dict_template_none(self):
|
||||
component = ChatPromptBuilder.from_dict(
|
||||
data={
|
||||
"type": "haystack.components.builders.chat_prompt_builder.ChatPromptBuilder",
|
||||
"init_parameters": {"template": None},
|
||||
}
|
||||
)
|
||||
|
||||
assert component.template is None
|
||||
assert component._variables is None
|
||||
assert component._required_variables is None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user