Home / Function/ test_prompttemplate_prefix_suffix() — langchain Function Reference

test_prompttemplate_prefix_suffix() — langchain Function Reference

Architecture documentation for the test_prompttemplate_prefix_suffix() function in test_few_shot_with_templates.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5fb8cd84_8b01_47c0_6ca2_b052cc08eb9c["test_prompttemplate_prefix_suffix()"]
  9d81a329_8337_d227_8d94_e1b1e6171d19["test_few_shot_with_templates.py"]
  5fb8cd84_8b01_47c0_6ca2_b052cc08eb9c -->|defined in| 9d81a329_8337_d227_8d94_e1b1e6171d19
  style 5fb8cd84_8b01_47c0_6ca2_b052cc08eb9c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_few_shot_with_templates.py lines 15–46

async def test_prompttemplate_prefix_suffix() -> 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"},
    ]
    prompt = FewShotPromptWithTemplates(
        suffix=suffix,
        prefix=prefix,
        input_variables=["content", "new_content"],
        examples=examples,
        example_prompt=EXAMPLE_PROMPT,
        example_separator="\n",
    )
    expected_output = (
        "This is a test about animals.\n"
        "foo: bar\n"
        "baz: foo\n"
        "Now you try to talk about party."
    )
    output = prompt.format(content="animals", new_content="party")
    assert output == expected_output
    output = await prompt.aformat(content="animals", new_content="party")
    assert output == expected_output

Domain

Subdomains

Frequently Asked Questions

What does test_prompttemplate_prefix_suffix() do?
test_prompttemplate_prefix_suffix() 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_prefix_suffix() defined?
test_prompttemplate_prefix_suffix() is defined in libs/core/tests/unit_tests/prompts/test_few_shot_with_templates.py at line 15.

Analyze Your Own Codebase

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

Try Supermodel Free