langchain/tests/unit_tests/prompts
engkheng dbbc340f25
Validate input_variables when using jinja2 templates (#3140)
`langchain.prompts.PromptTemplate` and
`langchain.prompts.FewShotPromptTemplate` do not validate
`input_variables` when initialized as `jinja2` template.

```python
# Using langchain v0.0.144
template = """"\
Your variable: {{ foo }}
{% if bar %}
You just set bar boolean variable to true
{% endif %}
"""

# Missing variable, should raise ValueError
prompt_template = PromptTemplate(template=template, 
                                 input_variables=["bar"], 
                                 template_format="jinja2", 
                                 validate_template=True)

# Extra variable, should raise ValueError
prompt_template = PromptTemplate(template=template, 
                                 input_variables=["bar", "foo", "extra", "thing"], 
                                 template_format="jinja2", 
                                 validate_template=True)
```
2023-04-19 16:18:32 -07:00
..
__init__.py add few shot example (#148) 2022-11-19 20:32:45 -08:00
test_chat.py Harrison/callbacks (#1587) 2023-03-10 12:53:09 -08:00
test_few_shot_with_templates.py Harrison/prompt template prefix (#888) 2023-02-06 19:09:28 -08:00
test_few_shot.py Validate input_variables when using jinja2 templates (#3140) 2023-04-19 16:18:32 -07:00
test_length_based_example_selector.py fix length based example selector (#862) 2023-02-02 22:06:56 -08:00
test_loading.py big docs refactor (#1978) 2023-03-26 19:49:46 -07:00
test_prompt.py Validate input_variables when using jinja2 templates (#3140) 2023-04-19 16:18:32 -07:00
test_utils.py Bug Fix (#221) 2022-11-29 07:03:40 -08:00