test_partial_init_string() — langchain Function Reference
Architecture documentation for the test_partial_init_string() function in test_few_shot.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 18381dd1_89ec_08a3_0655_46ec3cbf43f1["test_partial_init_string()"] e4e12a36_798e_ddc0_ab57_e44de269c7e7["test_few_shot.py"] 18381dd1_89ec_08a3_0655_46ec3cbf43f1 -->|defined in| e4e12a36_798e_ddc0_ab57_e44de269c7e7 style 18381dd1_89ec_08a3_0655_46ec3cbf43f1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/prompts/test_few_shot.py lines 147–171
def test_partial_init_string() -> None:
"""Test prompt can be initialized with partial variables."""
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=["new_content"],
partial_variables={"content": "animals"},
examples=examples,
example_prompt=EXAMPLE_PROMPT,
example_separator="\n",
)
output = prompt.format(new_content="party")
expected_output = (
"This is a test about animals.\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_init_string() do?
test_partial_init_string() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_few_shot.py.
Where is test_partial_init_string() defined?
test_partial_init_string() is defined in libs/core/tests/unit_tests/prompts/test_few_shot.py at line 147.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free