langchain/tests/unit_tests
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
..
agents Update Tool Input (#3103) 2023-04-18 18:18:33 -07:00
callbacks improve AsyncCallbackManager (#2410) 2023-04-05 09:31:42 +02:00
chains Factor out doc formatting and add validation (#3026) 2023-04-17 20:28:01 -07:00
data Prompt from file proof of concept using plain text (#127) 2022-11-13 13:15:30 -08:00
docstore Harrison/document cleanup (#2062) 2023-03-27 16:32:55 -07:00
document_loader rm pandas dependency (#2102) 2023-03-28 08:38:19 -07:00
evaluation Adding an in-context QA evaluation chain + chain of thought reasoning chain for improved accuracy (#2444) 2023-04-06 22:32:41 -07:00
llms Harrison/fix create sql agent (#2870) 2023-04-13 22:07:58 -07:00
output_parsers Nc/combining output parser (#3014) 2023-04-17 20:29:53 -07:00
prompts Validate input_variables when using jinja2 templates (#3140) 2023-04-19 16:18:32 -07:00
retrievers Generative Characters (#2859) 2023-04-16 21:41:00 -07:00
tools tools refactor (#2961) 2023-04-17 21:35:29 -07:00
utilities Centralize logic for loading from LangChainHub, add ability to pin dependencies (#805) 2023-01-30 14:52:17 -08:00
__init__.py initial commit 2022-10-24 14:51:15 -07:00
test_bash.py skip unit tests that fail in Windows (#2238) 2023-04-01 12:52:21 -07:00
test_formatting.py initial commit 2022-10-24 14:51:15 -07:00
test_python.py Move PythonRepl -> langchain.utilities (#2917) 2023-04-15 10:50:25 -07:00
test_sql_database_schema.py sql: do not hard code the LIMIT clause in the table_info section (#1563) 2023-03-13 23:08:27 -07:00
test_sql_database.py sql: do not hard code the LIMIT clause in the table_info section (#1563) 2023-03-13 23:08:27 -07:00
test_text_splitter.py Harrison/shallow metadata (#1599) 2023-03-11 09:18:25 -08:00