mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 20:09:01 +00:00
Fixing empty input variable crashing PromptTemplate
validations (#14314)
- Fixes `input_variables=[""]` crashing validations with a template `"{}"` - Uses `__cause__` for proper `Exception` chaining in `check_valid_template`
This commit is contained in:
@@ -47,6 +47,12 @@ def test_prompt_missing_input_variables() -> None:
|
||||
).input_variables == ["foo"]
|
||||
|
||||
|
||||
def test_prompt_empty_input_variable() -> None:
|
||||
"""Test error is raised when empty string input variable."""
|
||||
with pytest.raises(ValueError):
|
||||
PromptTemplate(input_variables=[""], template="{}", validate_template=True)
|
||||
|
||||
|
||||
def test_prompt_extra_input_variables() -> None:
|
||||
"""Test error is raised when there are too many input variables."""
|
||||
template = "This is a {foo} test."
|
||||
|
Reference in New Issue
Block a user