haystack icon indicating copy to clipboard operation
haystack copied to clipboard

Jinja2 Template Pitfall usinf f-Strings

Open Hansehart opened this issue 8 months ago • 0 comments

Describe the bug Hey, when using i. e. the PromptBuilder and f-Strings, take care of using quad-braces. Here is how it does not work:

template = f"""
The language tag is:
{language}

Request: {{ question }}
"""
prompt_builder = PromptBuilder(template=template)

Whereby it results for me in raise ValueError(f"Input {input_name} not found in component {component_name}.")

However using

template = f"""
The language tag is:
{language}

Request: {{{{ question }}}}
"""
prompt_builder = PromptBuilder(template=template)

works. Maybe it could be mentioned somewhere? documentation? Struggeld a bit on this.

Hansehart avatar May 19 '25 16:05 Hansehart