validate_jinja2() — langchain Function Reference
Architecture documentation for the validate_jinja2() function in string.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 96cbc2c0_d602_1b32_9641_52ef4f198968["validate_jinja2()"] a7a9f16f_a913_8e85_a792_d083dd92c428["string.py"] 96cbc2c0_d602_1b32_9641_52ef4f198968 -->|defined in| a7a9f16f_a913_8e85_a792_d083dd92c428 96cbc2c0_d602_1b32_9641_52ef4f198968["validate_jinja2()"] 96cbc2c0_d602_1b32_9641_52ef4f198968 -->|calls| 96cbc2c0_d602_1b32_9641_52ef4f198968 96cbc2c0_d602_1b32_9641_52ef4f198968["validate_jinja2()"] 96cbc2c0_d602_1b32_9641_52ef4f198968 -->|calls| 96cbc2c0_d602_1b32_9641_52ef4f198968 f53efb83_eef2_e36c_1360_c5fe4961e401["_get_jinja2_variables_from_template()"] 96cbc2c0_d602_1b32_9641_52ef4f198968 -->|calls| f53efb83_eef2_e36c_1360_c5fe4961e401 style 96cbc2c0_d602_1b32_9641_52ef4f198968 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/string.py lines 73–95
def validate_jinja2(template: str, input_variables: list[str]) -> None:
"""Validate that the input variables are valid for the template.
Issues a warning if missing or extra variables are found.
Args:
template: The template string.
input_variables: The input variables.
"""
input_variables_set = set(input_variables)
valid_variables = _get_jinja2_variables_from_template(template)
missing_variables = valid_variables - input_variables_set
extra_variables = input_variables_set - valid_variables
warning_message = ""
if missing_variables:
warning_message += f"Missing variables: {missing_variables} "
if extra_variables:
warning_message += f"Extra variables: {extra_variables}"
if warning_message:
warnings.warn(warning_message.strip(), stacklevel=7)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does validate_jinja2() do?
validate_jinja2() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/string.py.
Where is validate_jinja2() defined?
validate_jinja2() is defined in libs/core/langchain_core/prompts/string.py at line 73.
What does validate_jinja2() call?
validate_jinja2() calls 2 function(s): _get_jinja2_variables_from_template, validate_jinja2.
What calls validate_jinja2()?
validate_jinja2() is called by 1 function(s): validate_jinja2.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free