langchain/langchain/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
..
example_selector Fix small typo in SemanticSimilarityExampleSelector (#2629) 2023-04-09 12:53:02 -07:00
__init__.py chat model example (#2310) 2023-04-02 14:04:09 -07:00
base.py Validate input_variables when using jinja2 templates (#3140) 2023-04-19 16:18:32 -07:00
chat.py chat model example (#2310) 2023-04-02 14:04:09 -07:00
few_shot_with_templates.py Removed duplicate BaseModel dependencies (#2471) 2023-04-06 12:45:16 -07:00
few_shot.py Removed duplicate BaseModel dependencies (#2471) 2023-04-06 12:45:16 -07:00
loading.py consistently use getLogger(__name__), no root logger (#2989) 2023-04-16 12:49:35 -07:00
prompt.py Validate input_variables when using jinja2 templates (#3140) 2023-04-19 16:18:32 -07:00