Home / Function/ test_prompt_from_examples_valid() — langchain Function Reference

test_prompt_from_examples_valid() — langchain Function Reference

Architecture documentation for the test_prompt_from_examples_valid() function in test_prompt.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  37246156_f798_2d33_0adc_9a7453893fc4["test_prompt_from_examples_valid()"]
  af1b998b_a7bf_9d5c_32ef_bab507a6bee3["test_prompt.py"]
  37246156_f798_2d33_0adc_9a7453893fc4 -->|defined in| af1b998b_a7bf_9d5c_32ef_bab507a6bee3
  style 37246156_f798_2d33_0adc_9a7453893fc4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/prompts/test_prompt.py lines 308–339

def test_prompt_from_examples_valid() -> None:
    """Test prompt can be successfully constructed from examples."""
    template = """Test Prompt:

Question: who are you?
Answer: foo

Question: what are you?
Answer: bar

Question: {question}
Answer:"""
    input_variables = ["question"]
    example_separator = "\n\n"
    prefix = """Test Prompt:"""
    suffix = """Question: {question}\nAnswer:"""
    examples = [
        """Question: who are you?\nAnswer: foo""",
        """Question: what are you?\nAnswer: bar""",
    ]
    prompt_from_examples = PromptTemplate.from_examples(
        examples,
        suffix,
        input_variables,
        example_separator=example_separator,
        prefix=prefix,
    )
    prompt_from_template = PromptTemplate(
        input_variables=input_variables, template=template
    )
    assert prompt_from_examples.template == prompt_from_template.template
    assert prompt_from_examples.input_variables == prompt_from_template.input_variables

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free