Skip to content

Commit

Permalink
🔧 fix template vars with jinja2
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed May 17, 2024
1 parent 2b5fec2 commit c7504e4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/funcchain/backend/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ def create_instruction_prompt(

_filter_fstring_vars(input_kwargs)

inject_vars = [f"{var.upper()}:\n{{{var}}}\n" for var, _ in input_kwargs.items() if var not in required_f_str_vars]
if template_format == "jinja2":
inject_vars = [
f"{var.upper()}:\n{{{{{var}}}}}\n" for var, _ in input_kwargs.items() if var not in required_f_str_vars
]
else:
inject_vars = [
f"{var.upper()}:\n{{{var}}}\n" for var, _ in input_kwargs.items() if var not in required_f_str_vars
]

added_instruction = "\n".join(inject_vars)
instruction = added_instruction + instruction
Expand Down

0 comments on commit c7504e4

Please sign in to comment.