test_prompt_from_template() — langchain Function Reference
Architecture documentation for the test_prompt_from_template() function in test_prompt.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 8a294926_a8dc_d466_3ac3_6476daee1da9["test_prompt_from_template()"] af1b998b_a7bf_9d5c_32ef_bab507a6bee3["test_prompt.py"] 8a294926_a8dc_d466_3ac3_6476daee1da9 -->|defined in| af1b998b_a7bf_9d5c_32ef_bab507a6bee3 style 8a294926_a8dc_d466_3ac3_6476daee1da9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/prompts/test_prompt.py lines 51–69
def test_prompt_from_template() -> None:
"""Test prompts can be constructed from a template."""
# Single input variable.
template = "This is a {foo} test."
prompt = PromptTemplate.from_template(template)
expected_prompt = PromptTemplate(template=template, input_variables=["foo"])
assert prompt == expected_prompt
# Multiple input variables.
template = "This {bar} is a {foo} test."
prompt = PromptTemplate.from_template(template)
expected_prompt = PromptTemplate(template=template, input_variables=["bar", "foo"])
assert prompt == expected_prompt
# Multiple input variables with repeats.
template = "This {bar} is a {foo} test {foo}."
prompt = PromptTemplate.from_template(template)
expected_prompt = PromptTemplate(template=template, input_variables=["bar", "foo"])
assert prompt == expected_prompt
Domain
Subdomains
Source
Frequently Asked Questions
What does test_prompt_from_template() do?
test_prompt_from_template() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_prompt.py.
Where is test_prompt_from_template() defined?
test_prompt_from_template() is defined in libs/core/tests/unit_tests/prompts/test_prompt.py at line 51.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free