fix: template parse error when pre prompt include {{}} (#462)

This commit is contained in:
John Wang 2023-06-27 15:51:55 +08:00 committed by GitHub
parent c720f831af
commit 835bf9fd8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ class JinjaPromptTemplate(PromptTemplate):
def from_template(cls, template: str, **kwargs: Any) -> PromptTemplate:
"""Load a prompt template from a template."""
env = Environment()
template = template.replace("{{}}", "{}")
ast = env.parse(template)
input_variables = meta.find_undeclared_variables(ast)