mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-08-27 01:46:33 +00:00
fix: Change PromptBuilder
to have default values for all inputs (#6934)
* Change PromptBuilder to have default values for all inputs * Add release notes
This commit is contained in:
parent
929baf3961
commit
b49e86d007
@ -1,9 +1,8 @@
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Dict
|
||||
|
||||
from jinja2 import Template, meta
|
||||
|
||||
from haystack import component
|
||||
from haystack import default_to_dict
|
||||
from haystack import component, default_to_dict
|
||||
|
||||
|
||||
@component
|
||||
@ -31,7 +30,8 @@ class PromptBuilder:
|
||||
self.template = Template(template)
|
||||
ast = self.template.environment.parse(template)
|
||||
template_variables = meta.find_undeclared_variables(ast)
|
||||
component.set_input_types(self, **{var: Any for var in template_variables})
|
||||
for var in template_variables:
|
||||
component.set_input_type(self, var, Any, "")
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
return default_to_dict(self, template=self._template_string)
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix `PromptBuilder` missing input default values.
|
||||
These missing default value was causing the PromptBuilder to never run if certain inputs are not received.
|
Loading…
x
Reference in New Issue
Block a user