check_valid_template() — langchain Function Reference
Architecture documentation for the check_valid_template() function in string.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 88472679_8d5f_45ee_8c5f_0b4cf826d699["check_valid_template()"] a7a9f16f_a913_8e85_a792_d083dd92c428["string.py"] 88472679_8d5f_45ee_8c5f_0b4cf826d699 -->|defined in| a7a9f16f_a913_8e85_a792_d083dd92c428 88472679_8d5f_45ee_8c5f_0b4cf826d699["check_valid_template()"] 88472679_8d5f_45ee_8c5f_0b4cf826d699 -->|calls| 88472679_8d5f_45ee_8c5f_0b4cf826d699 88472679_8d5f_45ee_8c5f_0b4cf826d699["check_valid_template()"] 88472679_8d5f_45ee_8c5f_0b4cf826d699 -->|calls| 88472679_8d5f_45ee_8c5f_0b4cf826d699 style 88472679_8d5f_45ee_8c5f_0b4cf826d699 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/string.py lines 220–251
def check_valid_template(
template: str, template_format: str, input_variables: list[str]
) -> None:
"""Check that template string is valid.
Args:
template: The template string.
template_format: The template format.
Should be one of `'f-string'` or `'jinja2'`.
input_variables: The input variables.
Raises:
ValueError: If the template format is not supported.
ValueError: If the prompt schema is invalid.
"""
try:
validator_func = DEFAULT_VALIDATOR_MAPPING[template_format]
except KeyError as exc:
msg = (
f"Invalid template format {template_format!r}, should be one of"
f" {list(DEFAULT_FORMATTER_MAPPING)}."
)
raise ValueError(msg) from exc
try:
validator_func(template, input_variables)
except (KeyError, IndexError) as exc:
msg = (
"Invalid prompt schema; check for mismatched or missing input parameters"
f" from {input_variables}."
)
raise ValueError(msg) from exc
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does check_valid_template() do?
check_valid_template() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/string.py.
Where is check_valid_template() defined?
check_valid_template() is defined in libs/core/langchain_core/prompts/string.py at line 220.
What does check_valid_template() call?
check_valid_template() calls 1 function(s): check_valid_template.
What calls check_valid_template()?
check_valid_template() is called by 1 function(s): check_valid_template.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free