test_prompttemplate_validation() — langchain Function Reference
Architecture documentation for the test_prompttemplate_validation() function in test_few_shot_with_templates.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 789400e2_5729_c562_5f3c_4deb617b6253["test_prompttemplate_validation()"] 9d81a329_8337_d227_8d94_e1b1e6171d19["test_few_shot_with_templates.py"] 789400e2_5729_c562_5f3c_4deb617b6253 -->|defined in| 9d81a329_8337_d227_8d94_e1b1e6171d19 style 789400e2_5729_c562_5f3c_4deb617b6253 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/prompts/test_few_shot_with_templates.py lines 49–83
def test_prompttemplate_validation() -> None:
"""Test that few shot works when prefix and suffix are PromptTemplates."""
prefix = PromptTemplate(
input_variables=["content"], template="This is a test about {content}."
)
suffix = PromptTemplate(
input_variables=["new_content"],
template="Now you try to talk about {new_content}.",
)
examples = [
{"question": "foo", "answer": "bar"},
{"question": "baz", "answer": "foo"},
]
with pytest.raises(
ValueError,
match=re.escape("Got input_variables=[], but based on prefix/suffix expected"),
):
FewShotPromptWithTemplates(
suffix=suffix,
prefix=prefix,
input_variables=[],
examples=examples,
example_prompt=EXAMPLE_PROMPT,
example_separator="\n",
validate_template=True,
)
assert FewShotPromptWithTemplates(
suffix=suffix,
prefix=prefix,
input_variables=[],
examples=examples,
example_prompt=EXAMPLE_PROMPT,
example_separator="\n",
).input_variables == ["content", "new_content"]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_prompttemplate_validation() do?
test_prompttemplate_validation() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_few_shot_with_templates.py.
Where is test_prompttemplate_validation() defined?
test_prompttemplate_validation() is defined in libs/core/tests/unit_tests/prompts/test_few_shot_with_templates.py at line 49.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free