pre_init_validation() — langchain Function Reference
Architecture documentation for the pre_init_validation() function in prompt.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ec831a8d_7cb6_22ac_1b03_cb779e44bd3e["pre_init_validation()"] 21bd3731_3333_8ace_7023_5dd43ed308cf["PromptTemplate"] ec831a8d_7cb6_22ac_1b03_cb779e44bd3e -->|defined in| 21bd3731_3333_8ace_7023_5dd43ed308cf style ec831a8d_7cb6_22ac_1b03_cb779e44bd3e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/prompt.py lines 91–125
def pre_init_validation(cls, values: dict) -> Any:
"""Check that template and input variables are consistent."""
if values.get("template") is None:
# Will let pydantic fail with a ValidationError if template
# is not provided.
return values
# Set some default values based on the field defaults
values.setdefault("template_format", "f-string")
values.setdefault("partial_variables", {})
if values.get("validate_template"):
if values["template_format"] == "mustache":
msg = "Mustache templates cannot be validated."
raise ValueError(msg)
if "input_variables" not in values:
msg = "Input variables must be provided to validate the template."
raise ValueError(msg)
all_inputs = values["input_variables"] + list(values["partial_variables"])
check_valid_template(
values["template"], values["template_format"], all_inputs
)
if values["template_format"]:
values["input_variables"] = [
var
for var in get_template_variables(
values["template"], values["template_format"]
)
if var not in values["partial_variables"]
]
return values
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does pre_init_validation() do?
pre_init_validation() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/prompt.py.
Where is pre_init_validation() defined?
pre_init_validation() is defined in libs/core/langchain_core/prompts/prompt.py at line 91.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free