test_partial() — langchain Function Reference
Architecture documentation for the test_partial() function in test_few_shot.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 7828f6c5_91f0_f404_b8f8_8c74d8dc25f7["test_partial()"] e4e12a36_798e_ddc0_ab57_e44de269c7e7["test_few_shot.py"] 7828f6c5_91f0_f404_b8f8_8c74d8dc25f7 -->|defined in| e4e12a36_798e_ddc0_ab57_e44de269c7e7 style 7828f6c5_91f0_f404_b8f8_8c74d8dc25f7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/prompts/test_few_shot.py lines 201–233
def test_partial() -> None:
"""Test prompt can be partialed."""
prefix = "This is a test about {content}."
suffix = "Now you try to talk about {new_content}."
examples = [
{"question": "foo", "answer": "bar"},
{"question": "baz", "answer": "foo"},
]
prompt = FewShotPromptTemplate(
suffix=suffix,
prefix=prefix,
input_variables=["content", "new_content"],
examples=examples,
example_prompt=EXAMPLE_PROMPT,
example_separator="\n",
)
new_prompt = prompt.partial(content="foo")
new_output = new_prompt.format(new_content="party")
expected_output = (
"This is a test about foo.\n"
"foo: bar\n"
"baz: foo\n"
"Now you try to talk about party."
)
assert new_output == expected_output
output = prompt.format(new_content="party", content="bar")
expected_output = (
"This is a test about bar.\n"
"foo: bar\n"
"baz: foo\n"
"Now you try to talk about party."
)
assert output == expected_output
Domain
Subdomains
Source
Frequently Asked Questions
What does test_partial() do?
test_partial() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_few_shot.py.
Where is test_partial() defined?
test_partial() is defined in libs/core/tests/unit_tests/prompts/test_few_shot.py at line 201.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free