Home / Function/ test_partial_init_func() — langchain Function Reference

test_partial_init_func() — langchain Function Reference

Architecture documentation for the test_partial_init_func() function in test_few_shot.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  3b521f6c_a66f_bbaa_e7dc_d198ddf82fb9["test_partial_init_func()"]
  e4e12a36_798e_ddc0_ab57_e44de269c7e7["test_few_shot.py"]
  3b521f6c_a66f_bbaa_e7dc_d198ddf82fb9 -->|defined in| e4e12a36_798e_ddc0_ab57_e44de269c7e7
  style 3b521f6c_a66f_bbaa_e7dc_d198ddf82fb9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_few_shot.py lines 174–198

def test_partial_init_func() -> 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": lambda: "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

Frequently Asked Questions

What does test_partial_init_func() do?
test_partial_init_func() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_few_shot.py.
Where is test_partial_init_func() defined?
test_partial_init_func() is defined in libs/core/tests/unit_tests/prompts/test_few_shot.py at line 174.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free